High-level syntax control flags for template matching-related coding tools in video coding

ABSTRACT

A device for decoding video data comprises one or more processors configured to: obtain a syntax element from a bitstream that includes an encoded representation of the video data; determine, based on the syntax element, that a template-matching tool is enabled; based on the template-matching tool being enabled, applying the template-matching tool to generate a prediction block for a current coding unit (CU) of the video data; and reconstruct the current CU based on the prediction block for the current CU.

This application claims the benefit of U.S. Provisional PatentApplication 63/367,793, filed Jul. 6, 2022, the entire content of whichis incorporated by reference.

TECHNICAL FIELD

This disclosure relates to video encoding and video decoding.

BACKGROUND

Digital video capabilities can be incorporated into a wide range ofdevices, including digital televisions, digital direct broadcastsystems, wireless broadcast systems, personal digital assistants (PDAs),laptop or desktop computers, tablet computers, e-book readers, digitalcameras, digital recording devices, digital media players, video gamingdevices, video game consoles, cellular or satellite radio telephones,so-called “smart phones,” video teleconferencing devices, videostreaming devices, and the like. Digital video devices implement videocoding techniques, such as those described in the standards defined byMPEG-2, MPEG-4, ITU-T H.263, ITU-T H.264/MPEG-4, Part 10, Advanced VideoCoding (AVC), ITU-T H.265/High Efficiency Video Coding (HEVC), ITU-TH.266/Versatile Video Coding (VVC), and extensions of such standards, aswell as proprietary video codecs/formats such as AOMedia Video 1 (AV1)that was developed by the Alliance for Open Media. The video devices maytransmit, receive, encode, decode, and/or store digital videoinformation more efficiently by implementing such video codingtechniques.

Video coding techniques include spatial (intra-picture) predictionand/or temporal (inter-picture) prediction to reduce or removeredundancy inherent in video sequences. For block-based video coding, avideo slice (e.g., a video picture or a portion of a video picture) maybe partitioned into video blocks, which may also be referred to ascoding tree units (CTUs), coding units (CUs) and/or coding nodes. Videoblocks in an intra-coded (I) slice of a picture are encoded usingspatial prediction with respect to reference samples in neighboringblocks in the same picture. Video blocks in an inter-coded (P or B)slice of a picture may use spatial prediction with respect to referencesamples in neighboring blocks in the same picture or temporal predictionwith respect to reference samples in other reference pictures. Picturesmay be referred to as frames, and reference pictures may be referred toas reference frames.

SUMMARY

In general, this disclosure describes techniques related to high-levelsyntax control for template matching related tools. The disclosedmethods can be applied to any of the existing video codecs, such as HEVC(High Efficiency Video Coding), VVC (Versatile Video Coding), EssentialVideo Coding (EVC) or be an efficient coding feature in future videocoding standards (e.g., ECM (Enhanced Compression Model)). ECM and othervideo codecs may implement a variety of template matching tools.However, for specific types of video content or when targeting specifictypes of video decoders, it may not be advantageous to use one or moreof the template matching tools. For instance, less sophisticated videodecoders may not have the computational resources to use the templatematching tools. However, encoded bitstreams do not include dataindicating whether template matching tools are enabled. This may lead todecoding problems, such as decoding errors, if a video decoder attemptsto decode a bitstream generated using template matching tools that thevideo decoder is not equipped to use.

Techniques of this disclosure may address this problem. For instance, avideo encoder may signal a syntax element that indicates whether atemplate-matching tool is enabled. If the template-matching tool beingenabled, the video encoder may apply the template-matching tool togenerate a prediction block for a current CU of the video data.Similarly, a video decoder may obtain a syntax element from a bitstreamthat includes an encoded representation of the video data. Depending onthe value of the syntax element, the video decoder may apply thetemplate-matching tool to generate a prediction block for a currentcoding unit (CU) of the video data. Because the video encoder signalsthe syntax element, the decoding problems discussed above may beavoided.

In one example, this disclosure describes a device for decoding videodata, the device comprising: a memory comprising one or more storagemedia, the memory configured to store the video data; and one or moreprocessors implemented in circuitry, the one or more processorsconfigured to: obtain a syntax element from a bitstream that includes anencoded representation of the video data; determine, based on the syntaxelement, that a template-matching tool is enabled; based on thetemplate-matching tool being enabled, apply the template-matching toolto generate a prediction block for a current coding unit (CU) of thevideo data; and reconstruct the current CU based on the prediction blockfor the current CU.

In another example, this disclosure describes a device for encodingvideo data, the device comprising: a memory comprising one or morestorage media, the memory configured to store the video data; and one ormore processors implemented in circuitry, the one or more processorsconfigured to: signal, in a bitstream that includes an encodedrepresentation of the video data, a syntax element that indicateswhether a template-matching tool is enabled; based on thetemplate-matching tool being enabled, apply the template-matching toolto generate a prediction block for a current coding unit (CU) of thevideo data; and encode the current CU based on the prediction block forthe current CU.

In another example, this disclosure describes a method of decoding videodata, the method comprising: obtaining a syntax element from a bitstreamthat includes an encoded representation of the video data; determining,based on the syntax element, that a template-matching tool is enabled;based on the template-matching tool being enabled, applying thetemplate-matching tool to generate a prediction block for a currentcoding unit (CU) of the video data; and reconstructing the current CUbased on the prediction block for the current CU.

In another example, this disclosure describes a method of encoding videodata, the method comprising: signaling, in a bitstream that includes anencoded representation of the video data, a syntax element thatindicates whether a template-matching tool is enabled; based on thetemplate-matching tool being enabled, applying the template-matchingtool to generate a prediction block for a current coding unit (CU) ofthe video data; and encoding the current CU based on the predictionblock for the current CU.

In one example, this disclosure describes a method of decoding videodata, the method comprising: obtaining a syntax element from a bitstreamthat includes an encoded representation of the video data; determining,based on the syntax element, that a template-matching tool is enabled;based on the template-matching tool being enabled, applying thetemplate-matching tool to generate a prediction block for a currentcoding unit (CU) of the video data; and reconstructing the current CUbased on the prediction block for the current CU.

In another example, this disclosure describes a method of encoding videodata, the method comprising: signaling a syntax element in a bitstreamthat includes an encoded representation of the video data, a syntaxelement, wherein the syntax element indicates that a template-matchingtool is enabled; based on the template-matching tool being enabled,applying the template-matching tool to generate a prediction block for acurrent coding unit (CU) of the video data; and encoding the current CUbased on the prediction block for the current CU.

In another example, this disclosure describes a device includes one ormore means for performing the method of any of claims of thisdisclosure.

In another example, a computer-readable storage medium is encoded withinstructions that, when executed, cause a programmable processor toperform the method of any of claims of this disclosure.

The details of one or more examples are set forth in the accompanyingdrawings and the description below. Other features, objects, andadvantages will be apparent from the description, drawings, and claims.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram illustrating an example video encoding anddecoding system that may perform the techniques of this disclosure.

FIG. 2A and FIG. 2B are conceptual diagrams illustrating spatialneighboring motion vector (MV) candidates for merge mode and AdvancedMotion Vector Prediction (AMVP) modes.

FIG. 3A and FIG. 3B are conceptual diagrams illustrating a temporalmotion vector predictor (TMVP) candidate and MV scaling.

FIG. 4 is a conceptual diagram illustrating template matching on asearch area around an initial motion vector.

FIG. 5 is a conceptual diagram illustrating template and referencesamples of a template in reference pictures.

FIG. 6 is a conceptual diagram illustrating template and referencesamples of a template of a current block with sub-block motion using themotion information of the subblocks of the current block.

FIG. 7 is a conceptual diagram illustrating an edge on templates.

FIG. 8 is a conceptual diagram illustrating additional directions alongk×π/8 diagonal angles.

FIG. 9 is a conceptual diagram illustrating an example template forTM-OBMC.

FIG. 10 is a conceptual diagram illustrating an example intra templatematching search area.

FIG. 11 is a conceptual diagram illustrating intra block copy referenceregion depending on a current coding unit (CU) position.

FIG. 12 is a block diagram illustrating an example video encoder thatmay perform the techniques of this disclosure.

FIG. 13 is a block diagram illustrating an example video decoder thatmay perform the techniques of this disclosure.

FIG. 14 is a flowchart illustrating an example method for encoding acurrent block in accordance with the techniques of this disclosure.

FIG. 15 is a flowchart illustrating an example method for decoding acurrent block in accordance with the techniques of this disclosure.

FIG. 16 is a flowchart illustrating an example operation of a videoencoder in accordance with the techniques of this disclosure.

FIG. 17 is a flowchart illustrating an example operation of a videodecoder in accordance with the techniques of this disclosure.

DETAILED DESCRIPTION

A video coder (e.g., a video encoder or a video decoder) may usetemplate matching coding tools to generate prediction block for codingunits (CUs) of video data. In Enhanced Compression Model (ECM) proposalsthere is no systematic design for high-level syntax to switch templatematching coding tools on and off. This disclosure describes high levelsyntax elements for enabling or disabling template matching codingtools. The use of high-level syntax elements for enabling and disablingtemplate matching coding tools may enhance coding efficiency, accelerateencoding and/or decoding speeds, and/or provide other advantages.

For example, a video encoder may signal, in a bitstream that includes anencoded representation of the video data, a syntax element thatindicates whether a template-matching tool is enabled. Based on thetemplate-matching tool being enabled, the video encoder may apply thetemplate-matching tool to generate a prediction block for a current CUof the video data. The video encoder may encode the current CU based onthe prediction block for the current CU. Similarly, a video decoder mayobtain a syntax element from a bitstream that includes an encodedrepresentation of the video data. The video decoder may determine, basedon the syntax element, that a template-matching tool is enabled. Basedon the template-matching tool being enabled, the video decoder may applythe template-matching tool to generate a prediction block for a currentcoding unit (CU) of the video data. The video decoder may reconstructthe current CU based on the prediction block for the current CU. Bysignaling the syntax element that indicates whether thetemplate-matching tool is enabled, it may be determined, prior to thevideo decoder attempting to reconstruct the current CU or the bitstream,whether the video decoder is configured to decode the current CU or thebitstream. By avoiding attempts to decode a CU or bitstream that thevideo decoder is unable to decode, decoding errors may be avoided.

FIG. 1 is a block diagram illustrating an example video encoding anddecoding system 100 that may perform the techniques of this disclosure.The techniques of this disclosure are generally directed to coding(encoding and/or decoding) video data. In general, video data includesany data for processing a video. Thus, video data may include raw,unencoded video, encoded video, decoded (e.g., reconstructed) video, andvideo metadata, such as signaling data.

As shown in FIG. 1 , system 100 includes a source device 102 thatprovides encoded video data to be decoded and displayed by a destinationdevice 116. In particular, source device 102 provides encoded video datato destination device 116 via a computer-readable medium 110. Sourcedevice 102 and destination device 116 may comprise any of a wide rangeof devices, including desktop computers, notebook (i.e., laptop)computers, mobile devices, tablet computers, set-top boxes, telephonehandsets such as smartphones, televisions, cameras, display devices,digital media players, video gaming consoles, video streaming device,broadcast receiver devices, or the like. In some cases, source device102 and destination device 116 may be equipped for wirelesscommunication, and thus may be referred to as wireless communicationdevices.

In the example of FIG. 1 , source device 102 includes video source 104,memory 106, video encoder 200, and output interface 108. Destinationdevice 116 includes input interface 122, video decoder 300, memory 120,and display device 118. In accordance with this disclosure, videoencoder 200 of source device 102 and video decoder 300 of destinationdevice 116 may be configured to apply the techniques for templatematching-related coding tools. Thus, source device 102 represents anexample of a video encoding device, while destination device 116represents an example of a video decoding device. In other examples, asource device and a destination device may include other components orarrangements. For example, source device 102 may receive video data froman external video source, such as an external camera. Likewise,destination device 116 may interface with an external display device,rather than include an integrated display device.

System 100 as shown in FIG. 1 is merely one example. In general, anydigital video encoding and/or decoding device may perform techniques fortemplate matching-related coding tools. Source device 102 anddestination device 116 are merely examples of such coding devices inwhich source device 102 generates coded video data for transmission todestination device 116. This disclosure refers to a “coding” device as adevice that performs coding (encoding and/or decoding) of data. Thus,video encoder 200 and video decoder 300 represent examples of codingdevices, in particular, a video encoder and a video decoder,respectively. In some examples, source device 102 and destination device116 may operate in a substantially symmetrical manner such that each ofsource device 102 and destination device 116 includes video encoding anddecoding components. Hence, system 100 may support one-way or two-wayvideo transmission between source device 102 and destination device 116,e.g., for video streaming, video playback, video broadcasting, or videotelephony.

In general, video source 104 represents a source of video data (i.e.,raw, unencoded video data) and provides a sequential series of pictures(also referred to as “frames”) of the video data to video encoder 200,which encodes data for the pictures. Video source 104 of source device102 may include a video capture device, such as a video camera, a videoarchive containing previously captured raw video, and/or a video feedinterface to receive video from a video content provider. As a furtheralternative, video source 104 may generate computer graphics-based dataas the source video, or a combination of live video, archived video, andcomputer-generated video. In each case, video encoder 200 encodes thecaptured, pre-captured, or computer-generated video data. Video encoder200 may rearrange the pictures from the received order (sometimesreferred to as “display order”) into a coding order for coding. Videoencoder 200 may generate a bitstream including encoded video data.Source device 102 may then output the encoded video data via outputinterface 108 onto computer-readable medium 110 for reception and/orretrieval by, e.g., input interface 122 of destination device 116.

Memory 106 of source device 102 and memory 120 of destination device 116represent general purpose memories. Memory 106 and memory 120 mayinclude one or more storage media. such as RAM, ROM, EEPROM, CD-ROM orother optical disk storage, magnetic disk storage, or other magneticstorage devices, flash memory, or any other medium that can be used tostore data or program code. In some examples, memories 106, 120 maystore raw video data, e.g., raw video from video source 104 and raw,decoded video data from video decoder 300. Additionally oralternatively, memories 106, 120 may store software instructionsexecutable by, e.g., video encoder 200 and video decoder 300,respectively. Although memory 106 and memory 120 are shown separatelyfrom video encoder 200 and video decoder 300 in this example, it shouldbe understood that video encoder 200 and video decoder 300 may alsoinclude internal memories for functionally similar or equivalentpurposes. Furthermore, memories 106, 120 may store encoded video data,e.g., output from video encoder 200 and input to video decoder 300. Insome examples, portions of memories 106, 120 may be allocated as one ormore video buffers, e.g., to store raw, decoded, and/or encoded videodata.

Computer-readable medium 110 may represent any type of medium or devicecapable of transporting the encoded video data from source device 102 todestination device 116. In one example, computer-readable medium 110represents a communication medium to enable source device 102 totransmit encoded video data directly to destination device 116 inreal-time, e.g., via a radio frequency network or computer-basednetwork. Output interface 108 may modulate a transmission signalincluding the encoded video data, and input interface 122 may demodulatethe received transmission signal, according to a communication standard,such as a wireless communication protocol. The communication medium maycomprise any wireless or wired communication medium, such as a radiofrequency (RF) spectrum or one or more physical transmission lines. Thecommunication medium may form part of a packet-based network, such as alocal area network, a wide-area network, or a global network such as theInternet. The communication medium may include routers, switches, basestations, or any other equipment that may be useful to facilitatecommunication from source device 102 to destination device 116.

In some examples, source device 102 may output encoded data from outputinterface 108 to storage device 112. Similarly, destination device 116may access encoded data from storage device 112 via input interface 122.Storage device 112 may include any of a variety of distributed orlocally accessed data storage media such as a hard drive, Blu-ray discs,DVDs, CD-ROMs, flash memory, volatile or non-volatile memory, or anyother suitable digital storage media for storing encoded video data.

In some examples, source device 102 may output encoded video data tofile server 114 or another intermediate storage device that may storethe encoded video data generated by source device 102. Destinationdevice 116 may access stored video data from file server 114 viastreaming or download.

File server 114 may be any type of server device capable of storingencoded video data and transmitting that encoded video data to thedestination device 116. File server 114 may represent a web server(e.g., for a website), a server configured to provide a file transferprotocol service (such as File Transfer Protocol (FTP) or File Deliveryover Unidirectional Transport (FLUTE) protocol), a content deliverynetwork (CDN) device, a hypertext transfer protocol (HTTP) server, aMultimedia Broadcast Multicast Service (MBMS) or Enhanced MBMS (eMBMS)server, and/or a network attached storage (NAS) device. File server 114may, additionally or alternatively, implement one or more HTTP streamingprotocols, such as Dynamic Adaptive Streaming over HTTP (DASH), HTTPLive Streaming (HLS), Real Time Streaming Protocol (RTSP), HTTP DynamicStreaming, or the like.

Destination device 116 may access encoded video data from file server114 through any standard data connection, including an Internetconnection. This may include a wireless channel (e.g., a Wi-Ficonnection), a wired connection (e.g., digital subscriber line (DSL),cable modem, etc.), or a combination of both that is suitable foraccessing encoded video data stored on file server 114. Input interface122 may be configured to operate according to any one or more of thevarious protocols discussed above for retrieving or receiving media datafrom file server 114, or other such protocols for retrieving media data.

Output interface 108 and input interface 122 may represent wirelesstransmitters/receivers, modems, wired networking components (e.g.,Ethernet cards), wireless communication components that operateaccording to any of a variety of IEEE 802.11 standards, or otherphysical components. In examples where output interface 108 and inputinterface 122 comprise wireless components, output interface 108 andinput interface 122 may be configured to transfer data, such as encodedvideo data, according to a cellular communication standard, such as 4G,4G-LTE (Long-Term Evolution), LTE Advanced, 5G, or the like. In someexamples where output interface 108 comprises a wireless transmitter,output interface 108 and input interface 122 may be configured totransfer data, such as encoded video data, according to other wirelessstandards, such as an IEEE 802.11 specification, an IEEE 802.15specification (e.g., ZigBee™), a Bluetooth™ standard, or the like. Insome examples, source device 102 and/or destination device 116 mayinclude respective system-on-a-chip (SoC) devices. For example, sourcedevice 102 may include an SoC device to perform the functionalityattributed to video encoder 200 and/or output interface 108, anddestination device 116 may include an SoC device to perform thefunctionality attributed to video decoder 300 and/or input interface122.

The techniques of this disclosure may be applied to video coding insupport of any of a variety of multimedia applications, such asover-the-air television broadcasts, cable television transmissions,satellite television transmissions, Internet streaming videotransmissions, such as dynamic adaptive streaming over HTTP (DASH),digital video that is encoded onto a data storage medium, decoding ofdigital video stored on a data storage medium, or other applications.

Input interface 122 of destination device 116 receives an encoded videobitstream from computer-readable medium 110 (e.g., a communicationmedium, storage device 112, file server 114, or the like). The encodedvideo bitstream may include signaling information defined by videoencoder 200, which is also used by video decoder 300, such as syntaxelements having values that describe characteristics and/or processingof video blocks or other coded units (e.g., slices, pictures, groups ofpictures, sequences, or the like). Display device 118 displays decodedpictures of the decoded video data to a user. Display device 118 mayrepresent any of a variety of display devices such as a liquid crystaldisplay (LCD), a plasma display, an organic light emitting diode (OLED)display, or another type of display device.

Although not shown in FIG. 1 , in some examples, video encoder 200 andvideo decoder 300 may each be integrated with an audio encoder and/oraudio decoder, and may include appropriate MUX-DEMUX units, or otherhardware and/or software, to handle multiplexed streams including bothaudio and video in a common data stream.

Video encoder 200 and video decoder 300 each may be implemented as anyof a variety of suitable encoder and/or decoder circuitry, such as oneor more microprocessors, digital signal processors (DSPs), applicationspecific integrated circuits (ASICs), field programmable gate arrays(FPGAs), discrete logic, software, hardware, firmware or anycombinations thereof. When the techniques are implemented partially insoftware, a device may store instructions for the software in asuitable, non-transitory computer-readable medium and execute theinstructions in hardware using one or more processors to perform thetechniques of this disclosure. Each of video encoder 200 and videodecoder 300 may be included in one or more encoders or decoders, eitherof which may be integrated as part of a combined encoder/decoder (CODEC)in a respective device. A device including video encoder 200 and/orvideo decoder 300 may comprise an integrated circuit, a microprocessor,and/or a wireless communication device, such as a cellular telephone.

Video encoder 200 and video decoder 300 may operate according to a videocoding standard, such as ITU-T H.265, also referred to as HighEfficiency Video Coding (HEVC) or extensions thereto, such as themulti-view and/or scalable video coding extensions. Alternatively, videoencoder 200 and video decoder 300 may operate according to otherproprietary or industry standards, such as ITU-T H.266, also referred toas Versatile Video Coding (VVC). In other examples, video encoder 200and video decoder 300 may operate according to a proprietary videocodec/format, such as AOMedia Video 1 (AV1), extensions of AV1, and/orsuccessor versions of AV1 (e.g., AV2). In other examples, video encoder200 and video decoder 300 may operate according to other proprietaryformats or industry standards. The techniques of this disclosure,however, are not limited to any particular coding standard or format. Ingeneral, video encoder 200 and video decoder 300 may be configured toperform the techniques of this disclosure in conjunction with any videocoding techniques that use template-matching tools.

In general, video encoder 200 and video decoder 300 may performblock-based coding of pictures. The term “block” generally refers to astructure including data to be processed (e.g., encoded, decoded, orotherwise used in the encoding and/or decoding process). For example, ablock may include a two-dimensional matrix of samples of luminanceand/or chrominance data. In general, video encoder 200 and video decoder300 may code video data represented in a YUV (e.g., Y, Cb, Cr) format.That is, rather than coding red, green, and blue (RGB) data for samplesof a picture, video encoder 200 and video decoder 300 may code luminanceand chrominance components, where the chrominance components may includeboth red hue and blue hue chrominance components. In some examples,video encoder 200 converts received RGB formatted data to a YUVrepresentation prior to encoding, and video decoder 300 converts the YUVrepresentation to the RGB format. Alternatively, pre- andpost-processing units (not shown) may perform these conversions.

This disclosure may generally refer to coding (e.g., encoding anddecoding) of pictures to include the process of encoding or decodingdata of the picture. Similarly, this disclosure may refer to coding ofblocks of a picture to include the process of encoding or decoding datafor the blocks, e.g., prediction and/or residual coding. An encodedvideo bitstream generally includes a series of values for syntaxelements representative of coding decisions (e.g., coding modes) andpartitioning of pictures into blocks. Thus, references to coding apicture or a block should generally be understood as coding values forsyntax elements forming the picture or block.

HEVC defines various blocks, including coding units (CUs), predictionunits (PUs), and transform units (TUs). According to HEVC, a video coder(such as video encoder 200) partitions a coding tree unit (CTU) into CUsaccording to a quadtree structure. That is, the video coder partitionsCTUs and CUs into four equal, non-overlapping squares, and each node ofthe quadtree has either zero or four child nodes. Nodes without childnodes may be referred to as “leaf nodes,” and CUs of such leaf nodes mayinclude one or more PUs and/or one or more TUs. The video coder mayfurther partition PUs and TUs. For example, in HEVC, a residual quadtree(RQT) represents partitioning of TUs. In HEVC, PUs representinter-prediction data, while TUs represent residual data. CUs that areintra-predicted include intra-prediction information, such as anintra-mode indication.

As another example, video encoder 200 and video decoder 300 may beconfigured to operate according to VVC. According to VVC, a video coder(such as video encoder 200) partitions a picture into a plurality ofcoding tree units (CTUs). Video encoder 200 may partition a CTUaccording to a tree structure, such as a quadtree-binary tree (QTBT)structure or Multi-Type Tree (MTT) structure. The QTBT structure removesthe concepts of multiple partition types, such as the separation betweenCUs, PUs, and TUs of HEVC. A QTBT structure includes two levels: a firstlevel partitioned according to quadtree partitioning, and a second levelpartitioned according to binary tree partitioning. A root node of theQTBT structure corresponds to a CTU. Leaf nodes of the binary treescorrespond to coding units (CUs).

In an MTT partitioning structure, blocks may be partitioned using aquadtree (QT) partition, a binary tree (BT) partition, and one or moretypes of triple tree (TT) (also called ternary tree (TT)) partitions. Atriple or ternary tree partition is a partition where a block is splitinto three sub-blocks. In some examples, a triple or ternary treepartition divides a block into three sub-blocks without dividing theoriginal block through the center. The partitioning types in MTT (e.g.,QT, BT, and TT), may be symmetrical or asymmetrical.

When operating according to the AV1 codec, video encoder 200 and videodecoder 300 may be configured to code video data in blocks. In AV1, thelargest coding block that can be processed is called a superblock. InAV1, a superblock can be either 128×128 luma samples or 64×64 lumasamples. However, in successor video coding formats (e.g., AV2), asuperblock may be defined by different (e.g., larger) luma sample sizes.In some examples, a superblock is the top level of a block quadtree.Video encoder 200 may further partition a superblock into smaller codingblocks. Video encoder 200 may partition a superblock and other codingblocks into smaller blocks using square or non-square partitioning.Non-square blocks may include N/2×N, N×N/2, N/4×N, and N×N/4 blocks.Video encoder 200 and video decoder 300 may perform separate predictionand transform processes on each of the coding blocks.

AV1 also defines a tile of video data. A tile is a rectangular array ofsuperblocks that may be coded independently of other tiles. That is,video encoder 200 and video decoder 300 may encode and decode,respectively, coding blocks within a tile without using video data fromother tiles. However, video encoder 200 and video decoder 300 mayperform filtering across tile boundaries. Tiles may be uniform ornon-uniform in size. Tile-based coding may enable parallel processingand/or multi-threading for encoder and decoder implementations.

In some examples, video encoder 200 and video decoder 300 may use asingle QTBT or MTT structure to represent each of the luminance andchrominance components, while in other examples, video encoder 200 andvideo decoder 300 may use two or more QTBT or MTT structures, such asone QTBT/MTT structure for the luminance component and another QTBT/MTTstructure for both chrominance components (or two QTBT/MTT structuresfor respective chrominance components).

Video encoder 200 and video decoder 300 may be configured to usequadtree partitioning, QTBT partitioning, MTT partitioning, superblockpartitioning, or other partitioning structures.

In some examples, a CTU includes a coding tree block (CTB) of lumasamples, two corresponding CTBs of chroma samples of a picture that hasthree sample arrays, or a CTB of samples of a monochrome picture or apicture that is coded using three separate color planes and syntaxstructures used to code the samples. A CTB may be an N×N block ofsamples for some value of N such that the division of a component intoCTBs is a partitioning. A component is an array or single sample fromone of the three arrays (luma and two chroma) that compose a picture in4:2:0, 4:2:2, or 4:4:4 color format or the array or a single sample ofthe array that compose a picture in monochrome format. In some examples,a coding block is an M×N block of samples for some values of M and Nsuch that a division of a CTB into coding blocks is a partitioning.

The blocks (e.g., CTUs or CUs) may be grouped in various ways in apicture. As one example, a brick may refer to a rectangular region ofCTU rows within a particular tile in a picture. A tile may be arectangular region of CTUs within a particular tile column and aparticular tile row in a picture. A tile column refers to a rectangularregion of CTUs having a height equal to the height of the picture and awidth specified by syntax elements (e.g., such as in a picture parameterset). A tile row refers to a rectangular region of CTUs having a heightspecified by syntax elements (e.g., such as in a picture parameter set)and a width equal to the width of the picture.

In some examples, a tile may be partitioned into multiple bricks, eachof which may include one or more CTU rows within the tile. A tile thatis not partitioned into multiple bricks may also be referred to as abrick. However, a brick that is a true subset of a tile may not bereferred to as a tile. The bricks in a picture may also be arranged in aslice. A slice may be an integer number of bricks of a picture that maybe exclusively contained in a single network abstraction layer (NAL)unit. In some examples, a slice includes either a number of completetiles or only a consecutive sequence of complete bricks of one tile.

This disclosure may use “N×N” and “N by N” interchangeably to refer tothe sample dimensions of a block (such as a CU or other video block) interms of vertical and horizontal dimensions, e.g., 16×16 samples or 16by 16 samples. In general, a 16×16 CU will have 16 samples in a verticaldirection (y=16) and 16 samples in a horizontal direction (x=16).Likewise, an N×N CU generally has N samples in a vertical direction andN samples in a horizontal direction, where N represents a nonnegativeinteger value. The samples in a CU may be arranged in rows and columns.Moreover, CUs need not necessarily have the same number of samples inthe horizontal direction as in the vertical direction. For example, CUsmay comprise N×M samples, where M is not necessarily equal to N.

Video encoder 200 encodes video data for CUs representing predictionand/or residual information, and other information. The predictioninformation indicates how the CU is to be predicted in order to form aprediction block for the CU. The residual information generallyrepresents sample-by-sample differences between samples of the CU priorto encoding and the prediction block.

To predict a CU, video encoder 200 may generally form a prediction blockfor the CU through inter-prediction or intra-prediction.Inter-prediction generally refers to predicting the CU from data of apreviously coded picture, whereas intra-prediction generally refers topredicting the CU from previously coded data of the same picture. Toperform inter-prediction, video encoder 200 may generate the predictionblock using one or more motion vectors. Video encoder 200 may generallyperform a motion search to identify a reference block that closelymatches the CU, e.g., in terms of differences between the CU and thereference block. Video encoder 200 may calculate a difference metricusing a sum of absolute difference (SAD), sum of squared differences(SSD), mean absolute difference (MAD), mean squared differences (MSD),or other such difference calculations to determine whether a referenceblock closely matches the current CU. In some examples, video encoder200 may predict the current CU using uni-directional prediction orbi-directional prediction.

Some examples of VVC also provide an affine motion compensation mode,which may be considered an inter-prediction mode. In affine motioncompensation mode, video encoder 200 may determine two or more motionvectors that represent non-translational motion, such as zoom in or out,rotation, perspective motion, or other irregular motion types.

To perform intra-prediction, video encoder 200 may select anintra-prediction mode to generate the prediction block. Some examples ofVVC provide sixty-seven intra-prediction modes, including variousdirectional modes, as well as planar mode and DC mode. In general, videoencoder 200 selects an intra-prediction mode that describes neighboringsamples to a current block (e.g., a block of a CU) from which to predictsamples of the current block. Such samples may generally be above, aboveand to the left, or to the left of the current block in the same pictureas the current block, assuming video encoder 200 codes CTUs and CUs inraster scan order (left to right, top to bottom).

Video encoder 200 encodes data representing the prediction mode for acurrent block. For example, for inter-prediction modes, video encoder200 may encode data representing which of the various availableinter-prediction modes is used, as well as motion information for thecorresponding mode. For uni-directional or bi-directionalinter-prediction, for example, video encoder 200 may encode motionvectors using advanced motion vector prediction (AMVP) or merge mode.Video encoder 200 may use similar modes to encode motion vectors foraffine motion compensation mode.

AV1 includes two general techniques for encoding and decoding a codingblock of video data. The two general techniques are intra prediction(e.g., intra frame prediction or spatial prediction) and interprediction (e.g., inter frame prediction or temporal prediction). In thecontext of AV1, when predicting blocks of a current frame of video datausing an intra prediction mode, video encoder 200 and video decoder 300do not use video data from other frames of video data. For most intraprediction modes, video encoder 200 encodes blocks of a current framebased on the difference between sample values in the current block andpredicted values generated from reference samples in the same frame.Video encoder 200 determines predicted values generated from thereference samples based on the intra prediction mode.

Following prediction, such as intra-prediction or inter-prediction of ablock, video encoder 200 may calculate residual data for the block. Theresidual data, such as a residual block, represents sample by sampledifferences between the block and a prediction block for the block,formed using the corresponding prediction mode. Video encoder 200 mayapply one or more transforms to the residual block, to producetransformed data in a transform domain instead of the sample domain. Forexample, video encoder 200 may apply a discrete cosine transform (DCT),an integer transform, a wavelet transform, or a conceptually similartransform to residual video data. Additionally, video encoder 200 mayapply a secondary transform following the first transform, such as amode-dependent non-separable secondary transform (MDNSST), a signaldependent transform, a Karhunen-Loeve transform (KLT), or the like.Video encoder 200 produces transform coefficients following applicationof the one or more transforms.

As noted above, following any transforms to produce transformcoefficients, video encoder 200 may perform quantization of thetransform coefficients. Quantization generally refers to a process inwhich transform coefficients are quantized to possibly reduce the amountof data used to represent the transform coefficients, providing furthercompression. By performing the quantization process, video encoder 200may reduce the bit depth associated with some or all of the transformcoefficients. For example, video encoder 200 may round an n-bit valuedown to an m-bit value during quantization, where n is greater than m.In some examples, to perform quantization, video encoder 200 may performa bitwise right-shift of the value to be quantized.

Following quantization, video encoder 200 may scan the transformcoefficients, producing a one-dimensional vector from thetwo-dimensional matrix including the quantized transform coefficients.The scan may be designed to place higher energy (and therefore lowerfrequency) transform coefficients at the front of the vector and toplace lower energy (and therefore higher frequency) transformcoefficients at the back of the vector. In some examples, video encoder200 may utilize a predefined scan order to scan the quantized transformcoefficients to produce a serialized vector, and then entropy encode thequantized transform coefficients of the vector. In other examples, videoencoder 200 may perform an adaptive scan. After scanning the quantizedtransform coefficients to form the one-dimensional vector, video encoder200 may entropy encode the one-dimensional vector, e.g., according tocontext-adaptive binary arithmetic coding (CABAC). Video encoder 200 mayalso entropy encode values for syntax elements describing metadataassociated with the encoded video data for use by video decoder 300 indecoding the video data.

To perform CABAC, video encoder 200 may assign a context within acontext model to a symbol to be transmitted. The context may relate to,for example, whether neighboring values of the symbol are zero-valued ornot. The probability determination may be based on a context assigned tothe symbol.

Video encoder 200 may further generate syntax data, such as block-basedsyntax data, picture-based syntax data, and sequence-based syntax data,to video decoder 300, e.g., in a picture header, a block header, a sliceheader, or other syntax data, such as a sequence parameter set (SPS),picture parameter set (PPS), or video parameter set (VPS). Video decoder300 may likewise decode such syntax data to determine how to decodecorresponding video data.

In this manner, video encoder 200 may generate a bitstream includingencoded video data, e.g., syntax elements describing partitioning of apicture into blocks (e.g., CUs) and prediction and/or residualinformation for the blocks. Ultimately, video decoder 300 may receivethe bitstream and decode the encoded video data.

In general, video decoder 300 performs a reciprocal process to thatperformed by video encoder 200 to decode the encoded video data of thebitstream. For example, video decoder 300 may decode values for syntaxelements of the bitstream using CABAC in a manner substantially similarto, albeit reciprocal to, the CABAC encoding process of video encoder200. The syntax elements may define partitioning information forpartitioning of a picture into CTUs, and partitioning of each CTUaccording to a corresponding partition structure, such as a QTBTstructure, to define CUs of the CTU. The syntax elements may furtherdefine prediction and residual information for blocks (e.g., CUs) ofvideo data.

The residual information may be represented by, for example, quantizedtransform coefficients. Video decoder 300 may inverse quantize andinverse transform the quantized transform coefficients of a block toreproduce a residual block for the block. Video decoder 300 uses asignaled prediction mode (intra- or inter-prediction) and relatedprediction information (e.g., motion information for inter-prediction)to form a prediction block for the block. Video decoder 300 may thencombine the prediction block and the residual block (on asample-by-sample basis) to reproduce the original block. Video decoder300 may perform additional processing, such as performing a deblockingprocess to reduce visual artifacts along boundaries of the block.

This disclosure may generally refer to “signaling” certain information,such as syntax elements. The term “signaling” may generally refer to thecommunication of values for syntax elements and/or other data used todecode encoded video data. That is, video encoder 200 may signal valuesfor syntax elements in the bitstream. In general, signaling refers togenerating a value in the bitstream. As noted above, source device 102may transport the bitstream to destination device 116 substantially inreal time, or not in real time, such as might occur when storing syntaxelements to storage device 112 for later retrieval by destination device116.

In HEVC, the largest coding unit in a slice is called a coding treeblock (CTB) or coding tree unit (CTU). A CTB contains a quad-tree thenodes of which are coding units. The size of a CTB can be ranges from16×16 to 64×64 in the HEVC main profile (although technically 8×8 CTBsizes can be supported). A coding unit (CU) could be the same size of aCTB to as small as 8×8. Each coding unit is coded with one mode, e.g.,inter or intra. When a CU is inter-coded, the CU may be furtherpartitioned into 2 or 4 prediction units (PUs) or become just one PUwhen further partition does not apply. When two PUs are present in oneCU, they can be half size rectangles or two rectangle size with ¼ or ¾size of the CU. When the CU is inter-coded, each PU has one set ofmotion information, which is derived with a unique inter predictionmode.

In the HEVC standard, there are two inter prediction modes, named merge(skip is considered as a special case of merge) and advanced motionvector prediction (AMVP) modes respectively for a prediction unit (PU).In either AMVP or merge mode, a motion vector (MV) candidate list ismaintained for multiple motion vector predictors. The motion vector(s),as well as reference indices in the merge mode, of the current PU aregenerated by taking one candidate from the MV candidate list. The MVcandidate list contains up to 5 candidates for the merge mode and onlytwo candidates for the AMVP mode. A merge candidate may contain a set ofmotion information, e.g., motion vectors corresponding to both referencepicture lists (list 0 and list 1) and the reference indices. If a mergecandidate is identified by a merge index, the reference pictures usedfor the prediction of the current blocks, as well as the associatedmotion vectors are determined. On the other hand, under AMVP mode foreach potential prediction direction from either list 0 or list 1, areference index may be explicitly signaled, together with an MVpredictor (MVP) index to the MV candidate list since the AMVP candidatecontains only a motion vector. In AMVP mode, the predicted motionvectors can be further refined. The candidates for both modes arederived similarly from the same spatial and temporal neighboring blocks.

FIG. 2A and FIG. 2B are conceptual diagrams illustrating spatialneighboring MV candidates for merge mode and AMVP modes. Spatial MVcandidates are derived from the neighboring blocks shown in FIG. 2A andFIG. 2B, for a specific PU (PU₀) 250, although the methods generatingthe candidates from the blocks differ for merge and AMVP modes. FIG. 2Aand FIG. 2B also show an adjacent PU (PU₁) 252

In merge mode, up to four spatial MV candidates can be derived with theorders showed in FIG. 2A with numbers, and the order is the following:left (0, A1), above (1, B1), above right (2, B0), below left (3, A0),and above left (4, B2), as shown in FIG. 2A.

In AMVP mode, the neighboring blocks are divided into two groups: leftgroup consisting of block 0 and 1, and above group consisting of theblocks 2, 3, and 4 as shown in FIG. 2B. For each group, the potentialcandidate in a neighboring block referring to the same reference pictureas that indicated by the signaled reference index has the highestpriority to be chosen to form a final candidate of the group. It ispossible that none of the neighboring blocks contain a motion vectorpointing to the same reference picture. Therefore, if such a candidatecannot be found, the video coder (e.g., video encoder 200 or videodecoder 300) may scale the first available candidate to form the finalcandidate, thus the temporal distance differences can be compensated.

In HEVC, a temporal motion vector predictor (TMVP) candidate, if enabledand available, is added into the MV candidate list after spatial motionvector candidates. The process of motion vector derivation for a TMVPcandidate is the same for both merge and AMVP modes, however the targetreference index for the TMVP candidate in the merge mode is always setto 0.

FIG. 3A and FIG. 3B are conceptual diagrams illustrating a TMVPcandidate and MV scaling. A primary block location 350 for TMVPcandidate derivation for a current PU 352 (PU₀) is the bottom rightblock outside 354 of a collocated PU 356 (PU₁) as shown in FIG. 3A as ablock “T”, to compensate the bias to the above and left blocks used togenerate spatial neighboring candidates. However, if that block islocated outside of the current CTB row or motion information is notavailable (e.g., as shown by block 358), the block is substituted with acenter block 360 of current PU 352.

A motion vector for a TMVP candidate is derived from the co-located PUof the co-located picture, indicated in the slice level. The motionvector for the co-located PU is called collocated MV. Similar totemporal direct mode in AVC, to derive the TMVP candidate motion vector,the co-located MV may be scaled to compensate the temporal distancedifferences, as shown in FIG. 3A and FIG. 3B.

Motion vector scaling is now discussed. It is assumed that the value ofmotion vectors is proportional to the distance of pictures in thepresentation time. A motion vector associates two pictures, thereference picture, and the picture containing the motion vector (namelythe containing picture). When a motion vector is utilized to predict theother motion vector, the distance of the containing picture and thereference picture is calculated based on the Picture Order Count (POC)values.

For a motion vector to be predicted, both its associated containingpicture and reference picture may be different. Therefore, a newdistance (based on POC) is calculated. The motion vector is scaled basedon these two POC distances. For a spatial neighboring candidate, thecontaining pictures for the two motion vectors are the same, while thereference pictures are different. In HEVC, motion vector scaling appliesto both TMVP and AMVP for spatial and temporal neighboring candidates.

In the example of FIG. 3B, a current picture 370 has a current PU 372. ATMVP 374 of current PU 372 indicates a location in a current referencepicture 376. A current temporal distance 378 is the difference betweencurrent picture 370 and current reference picture 376. However, toderive TMVP 374, the video coder may refer to a collocated PU 380 thatis collocated with current PU 372. The picture containing collocated PU380 may be referred to as collocated picture 382. A motion vector ofcollocated PU 380 may be referred to as collocated MV 384. Collocated MV384 may indicate a location in another reference picture (referred to acollocated reference picture 386). The distance between collocatedpicture 382 and collocated reference picture 386 may be referred to ascollocated temporal distance 388. Collocated temporal distance 388 maybe different from current temporal distance 378. Accordingly, collocatedMV 384 is scaled based on collocated temporal distance 388 and currenttemporal distance 378 to determine TMVP 374.

Artificial motion vector candidate generation is now discussed. If amotion vector candidate list is not complete, video encoder 200 or videodecoder 300 may generate artificial motion vector candidates and mayinsert the artificial motion vector candidates at the end of the listuntil the list has all candidates. In merge mode, there are two types ofartificial MV candidates: combined candidate derived only for B-slicesand zero candidates used only for AMVP if the first type does notprovide enough artificial candidates.

For each pair of candidates that are already in the candidate list andhave necessary motion information, bi-directional combined motion vectorcandidates are derived by a combination of the motion vector of thefirst candidate referring to a picture in the list 0 and the motionvector of a second candidate referring to a picture in the list 1.

A pruning process for candidate insertion is now discussed. Candidatesfrom different blocks may happen to be the same, which decreases theefficiency of a merge/AMVP candidate list. A pruning process is appliedto solve this problem. The pruning process compares one candidateagainst the others in the current candidate list to avoid insertingidentical candidate in certain extent. To reduce the complexity, onlylimited numbers of comparisons are applied instead of comparing eachpotential one with all the other existing ones.

Template Matching Advanced Motion Vector Prediction (TM-AMVP) andTemplate Matching Merge (TM-MRG) are now discussed. Template matching(TM) is a decoder-side MV derivation method to refine the motioninformation of the current CU by finding the closest match between atemplate (i.e., top and/or left neighbouring blocks of the current CU)in the current picture and a block (i.e., same size to the template) ina reference picture. Template matching is applied to both AMVP andregular merge mode called respectively as TM-AMVP and TM-MRG modes.

FIG. 4 is a conceptual diagram illustrating template matching on asearch area around an initial motion vector. As illustrated in FIG. 4 ,a current frame 400 includes a current CU 402. A left current template404A and an above current template 404B (collectively, “currenttemplates 404”) are left and above current CU 402. An initial MV 406 forcurrent CU 402 may be determined. For instance, video encoder 200 maysignal information indicating initial MV to video decoder 300. Videoencoder 200 or video decoder 300 searches for a better MV around alocation indicated by initial MV 406 of current CU 402 within a searchrange 410 (e.g., a [−8, +8]-pel search range) within a reference frame408. The template matching method in Chen et al., “Description of SDR,HDR and 360° video coding technology proposal by Qualcomm andTechnicolor—low and high complexity versions”, Joint Video ExplorationTeam (JVET) of ITU-T SG 16 WP 3 and ISO/IEC JTC 1/SC 29/WG 11, 10thMeeting: San Diego, US, 10-20 Apr. 2018, document JVET-J0021(hereinafter, “JVET-J0021”) is used with the following modifications:search step size is determined based on adaptive motion vectorresolution (AMVR) mode and TM can be cascaded with bilateral matchingprocess in merge modes.

In TM-AMVP mode, an MVP candidate is determined based on templatematching error to select the MVP candidate which reaches the minimumdifference between the current block template and the reference blocktemplate 412, and then TM is performed only for this particular MVPcandidate for MV refinement. TM refines this MVP candidate, startingfrom full-pel MVD precision (or 4-pel for 4-pel AMVR mode) within a [−8,+8]-pel search range by using iterative diamond search. The AMVPcandidate may be further refined by using cross search with full-pel MVDprecision (or 4-pel for 4-pel AMVR mode), followed sequentially byhalf-pel and quarter-pel ones depending on AMVR mode as specified in thetable below. This search process ensures that the MVP candidate keepsthe same MV precision as indicated by the AMVR mode after TM process. Inthe search process, if the difference between the previous minimum costand the current minimum cost in the iteration is less than a thresholdthat is equal to the area of the block, the search process terminates.

TABLE 1 Search patterns of AMVR and merge mode with AMVR. AMVR modeMerge mode Search pattern 4-pel Full-pel Half-pel Quarter-pel AltIF = 0AltIF = 1 4-pel diamond v 4-pel cross v Full-pel diamond v v v v vFull-pel cross v v v v v Half-pel cross v v v v Quarter-pel cross v v⅛-pel cross v

In TM-MRG merge mode, similar search method is applied to the mergecandidate indicated by the merge index. As Table 1 shows, TM may performall the way down to ⅛-pel MVD precision or skipping those beyondhalf-pel MVD precision, depending on whether the alternativeinterpolation filter (that is used when AMVR is of half-pel mode) isused according to merged motion information. Besides, when TM mode isenabled, template matching may work as an independent process or anextra MV refinement process between block-based and subblock-basedbilateral matching (BM) methods, depending on whether BM can be enabledor not according to its enabling condition check.

Template matching is applied to geometric partition merge (GPM) mode,called as TM-GPM mode. When GPM is enabled for a CU, a CU-level flag issignaled to indicate whether TM is applied to both geometric partitions.Motion information for each geometric partition is refined using TM.When TM is chosen, a template is constructed using left, above or leftand above neighboring samples according to partition angle, as shown inTable 2. The motion is then refined by minimizing the difference betweenthe current template and the template in the reference picture using thesame search pattern of merge mode with half-pel interpolation filterdisabled.

TABLE 2 Template for the 1st and 2nd geometric partitions, where Arepresents using above samples, L represents using left samples, and L +A represents using both left and above samples. Partition angle 0 2 3 45 8 11 12 13 14 1st partition A A A A L + A L + A L + A L + A A A 2ndpartition L + A L + A L + A L L L L L + A L + A L + A Partition angle 1618 19 20 21 24 27 28 29 30 1st partition A A A A L + A L + A L + A L + AA A 2nd partition L + A L + A L + A L L L L L + A L + A L + A

A GPM candidate list may be constructed as follows:

-   -   1. Interleaved List-0 MV candidates and List-1 MV candidates are        derived directly from the regular merge candidate list, where        List-0 MV candidates are higher priority than List-1 MV        candidates. A pruning method with an adaptive threshold based on        the current CU size is applied to remove redundant MV        candidates.    -   2. Interleaved List-1 MV candidates and List-0 MV candidates are        further derived directly from the regular merge candidate list,        where List-1 MV candidates are higher priority than List-0 MV        candidates. The same pruning method with the adaptive threshold        is also applied to remove redundant MV candidates.    -   3. Zero MV candidates are padded until the GPM candidate list is        full.

Template matching with combined intra/inter prediction (TM-CIIP) is nowdiscussed. In CIIP mode, the prediction samples can be generated byweighting an inter prediction signal predicted using template matchingmerge candidate and an intra prediction signal. This mode is calledTM-CIIP. The TM-CIIP merge candidate list is built for the TM-CIIP mode.The merge candidates are refined by template matching. The CIIP-TM mergecandidates are also reordered by the ARMC method as regular mergecandidates. The maximum number of TM-CIIP merge candidates is equal totwo. When the sequence-level CIIP flag is enabled, a sequence-level flagfor TM-CIIP is present in the bitstream to determined whether TM-CIIPcan be used at coding-unit level.

Adaptive reordering of merge candidates (ARMC) is now discussed. Themerge candidates may be adaptively reordered with template matching(TM). The reordering method is applied to regular merge mode, templatematching (TM) merge mode, and affine merge mode (excluding the SbTMVPcandidate). For the TM merge mode, merge candidates are reordered beforethe refinement process. ARMC can be disabled from the reconstructionprocess by turning off its sequence-level flag.

After a merge candidate list is constructed, merge candidates aredivided into several subgroups. The subgroup size is set to 5 forregular merge mode and TM merge mode. The subgroup size is set to 3 foraffine merge mode. Merge candidates in each subgroup are reorderedascendingly according to cost values based on template matching. Forsimplification, merge candidates in the last but not the first subgroupare not reordered. All the zero candidates from the ARMC reorderingprocess are excluded during the construction of Merge motion vectorcandidates list.

The template matching cost of a merge candidate is measured by the sumof absolute differences (SAD) between samples of a template of thecurrent block and their corresponding reference samples. The templatecomprises a set of reconstructed samples neighboring to the currentblock. Reference samples of the template are located by the motioninformation of the merge candidate.

When a merge candidate utilizes bi-directional prediction, the referencesamples of the template of the merge candidate are also generated bybi-prediction as shown in FIG. 5 . FIG. 5 is a conceptual diagramillustrating template and reference samples of a template in referencepictures. In the example of FIG. 5 , a current picture 500 includes acurrent block 502. Templates are above and left of current block 502.The merge candidate for current block 502 may include List 0 motioninformation that identifies a reference picture in reference list 0(506) and List 1 motion information that identifies a reference picturein reference picture in reference list 1 (508). The List 0 motioninformation further includes an initial motion vector that indicates alocation in reference picture 506. The List 1 motion information furtherincludes an initial motion vector that indicates a location in referencepicture 508. Video encoder 200 and video decoder 300 may search areasaround the locations identified by the initial motion vectors toidentify reference blocks 510 and 512. Video encoder 200 and videodecoder 300 may identify reference blocks 510, 512 based on comparisonsof samples in template 504 to reference samples in correspondingtemplates 514, 516 of reference pictures 506, 508.

FIG. 6 is a conceptual diagram illustrating template and referencesamples of a template of a current block 600 with sub-block motion usingthe motion information of the subblocks of current block 600. A currentpicture 602 includes current block 600. A collocated picture 604includes a collocated block 606. For subblock-based merge candidateswith subblock size equal to Wsub×Hsub, the above template comprisesseveral sub-templates 608 with the size of Wsub×1, and the left templatecomprises several sub-templates 610 with the size of 1×Hsub. As shown inFIG. 6 , the motion information of the subblocks in the first row andthe first column of current block 600 is used to derive the referencesamples of each sub-template.

TMVP and non-adjacent merge candidate type reordering is now discussed.Merge candidates of one single candidate type, e.g., TMVP ornon-adjacent MVP (NA-MVP), are reordered based on the ARMC TM costvalues. The reordered candidates are then added into the merge candidatelist. The TMVP candidate type adds more TMVP candidates with moretemporal positions and different inter prediction directions to performthe reordering and the selection. Moreover, the NA-MVP candidate type isfurther extended with more spatially non-adjacent positions. The targetreference picture of the TMVP candidate can be selected from any one ofreference picture in the list according to scaling factor. The selectedreference picture is the one whose scaling factor is the closest to 1.

Geometric partition merge (GPM) split mode reordering is now discussed.In template matching based reordering for GPM split modes, given themotion information of the current GPM block, the respective TM costvalues of GPM split modes are computed. Then, all GPM split modes arereordered in ascending ordering based on the TM cost values. Instead ofsending GPM split mode, an index using Golomb-Rice code to indicatewhere the exact GPM split mode is located in the reordering list issignaled.

The reordering method for GPM split modes is a two-step processperformed after the respective reference templates of the two GPMpartitions in a coding unit are generated, as follows:

-   -   extending GPM partition edge into the reference templates of the        two GPM partitions, resulting in 64 reference templates and        computing the respective TM cost for each of the 64 reference        templates;    -   reordering GPM split modes based on their TM cost values in        ascending order and marking the best 32 as available split        modes.

The edge on the template is extended from that of the current CU, asFIG. 7 illustrates, but GPM blending process is not used in the templatearea across the edge. FIG. 7 is a conceptual diagram illustrating anedge on templates. Specifically, in the example of FIG. 7 , a current CU700 has a top template 702 and a left template 704. Current CU 700 ispartitioned by a GPM partition edge 706. After ascending reorderingusing TM cost, an index is signaled. The GPM split mode reordering hasits own sequence-level flag to control whether reordering is enabled ornot. When GPM split mode is disabled, GPM split mode is not reorderedfor the whole sequence and the syntax that represents GPM split modefalls back to the original design (that is a 6-bit binary code) as VTM.

Candidate reordering for regular Merge Mode with Motion VectorDifference (MMVD) and affine MMVD is now discussed. The MMVD offsets areextended for MMVD and affine MMVD modes. Additional refinement positionsalong k×π/8 diagonal angles are added shown in FIG. 8 , thus increasingthe number of directions from 4 to 16. Second, based on the sum ofabsolute differences (SAD) cost between the template (one row above andone column left to the current block) and its reference for eachrefinement position, all the possible MMVD refinement positions (16×6)for each base candidate are reordered. Finally, the top ⅛ refinementpositions with the smallest template SAD costs are kept as availablepositions, consequently for MMVD index coding. The MMVD index isbinarized by the Rice code with the parameter equal to 2. The affineMMVD reordering is extended, in which additional refinement positionsalong k×π/4 diagonal angles are added. After reordering top ½ refinementpositions with the smallest template SAD costs are kept. FIG. 8 is aconceptual diagram illustrating additional directions along k×π/8diagonal angles. In FIG. 8 , a star symbol 800 represents a location ina reference frame to which a base motion vector of MMVD points. Relativeto the position of star symbol 800, the 16 circles (802A-802P) (black,shaded, blank) represent directions toward which the base motion vectorcan be refined. There are 16 directions that correspond respectively to16 angles (as denoted as {k×π/8, for all kϵ{0, 1, . . . , 15}}).Specifically, they are {(±1, 0), (0, ±1), (−1, ±1), (1, ±1), (−1, ±2),(1, ±2), (−2, ±1), (2, ±1)} as supported in ECM's MMVD mode. Inaddition, only the first half of the directions are supported in ECM'saffine MMVD. A final motion vector may be a base motion vector plus adifference vector derived by a selected direction vector multiplied by aselected offset scalar.

MVD sign prediction is now discussed. In MVD sign prediction, possibleMVD sign combinations are sorted according to the template matching costand index corresponding to the true MVD sign is derived and contextcoded. At the decoder side, the MVD signs are derived as following:

-   -   1. Parse the magnitude of MVD components.    -   2. Parse context-coded MVD sign prediction index.    -   3. Build MV candidates by creating a combination between        possible signs and absolute MVD values and adding the        combination to the MV predictor.    -   4. Derive MVD sign prediction cost for each derived MV based on        template matching cost and sort.    -   5. Use MVD sign prediction index to pick the true MVD sign.

MVD sign prediction is applied to inter AMVP, affine AMVP, MMVD andaffine MMVD modes. A sequence-level flag is used to determine whetherMVD sign prediction is used in the bitstream. When this sequence-levelflag is off, the MVD sign bits are signaled in the same way as VTM andare not reordered.

Reference picture reordering is now discussed. A block level referencepicture reordering method based on template matching may be used. Forthe uni-prediction AMVP mode, the reference pictures in List 0 and List1 are interweaved to generate a joint list. For each hypothesis of thereference picture in the joint list template matching is performed tocalculate the cost. The joint list is reordered based on ascending orderof the template matching cost. The index of the selected referencepicture in the reordered joint list is signaled in the bitstream. Forthe bi-prediction AMVP mode, a list of pairs of reference pictures fromList 0 and List 1 is generated and similarly reordered based on thetemplate matching cost. The index of the selected pair is signaled.

A sequence-level flag is used to determine whether reference picturereordering is used in the bitstream. When this sequence-level flag isoff, the reference picture indices are signaled in the same way as VTMand are not reordered.

Template matching with overlapped block motion compensation (TM-OBMC) isnow discussed. In a template matching based overlapped block motioncompensation (OBMC) scheme, instead of directly using the weightedprediction, the prediction value of CU boundary samples derivationapproach is decided according to the template matching costs, includingusing current block's motion information only, or using neighboringblock's motion information as well with one of the blending modes.

FIG. 9 is a conceptual diagram illustrating example templates forTM-OBMC. In this scheme, for each top block (i.e., each of blocks 900A,900B, 900C, 900D) with a size of 4×4 at the top boundary of a CU 902,the above template size (e.g., templates 904A, 904B, 904C, 904D) equalsto 4×1. If N adjacent blocks have the same motion information, then theabove template size is enlarged to 4N×1 since the motion compensationoperation can be processed at one time. For each left block (i.e.,blocks 900A, 900E, 900F, 900G) with a size of 4×4 at the left CUboundary, the left template (904E, 904F, 904G, 904H size equals to 1×4or 1×4N (as depicted in FIG. 9 ).

Specifically, in the example of FIG. 9 , for each 4×4 top block (i.e.,each of blocks 900A, 900B, 900C, 900D) or other group of N 4×4 blocks,the prediction value of boundary samples is derived following the belowsteps.

Take block 900A as the current block and its above neighboring blockAboveNeighbor_A for example. The operation for left blocks is conductedin the same manner.

First, three template matching costs (Cost1, Cost2, Cost3) are measuredby SAD between the reconstructed samples of a template and itscorresponding reference samples derived by MC process according to thefollowing three types of motion information:

-   -   Cost1 is calculated according to A's motion information.    -   Cost2 is calculated according to AboveNeighbor_A's motion        information.    -   Cost3 is calculated according to weighted prediction of A's and        AboveNeighbor_A's motion information with weighting factors as ¾        and ¼ respectively.

Second, choose one approach to calculate the final prediction results ofboundary samples by comparing Cost1, Cost2 and Cost 3.

The original motion compensation result using current block's motioninformation is denoted as Pixel1, and the motion compensation resultusing neighboring block's motion information is denoted as Pixel2. Thefinal prediction result is denoted as NewPixel.

-   -   If Cost1 is minimum, then NewPixel(i,j)=Pixel1(i,j).    -   If (Cost2+(Cost2>>2)+(Cost2>>3))<=Cost1, then blending mode 1 is        used.        -   For luma blocks, the number of blending pixel rows is 4.

NewPixel(i,0)=(26×Pixel1(i,0)+6×Pixel2(i,0)+16)>>5

NewPixel(i,1)=(7×Pixel1(i,1)+Pixel2(i,1)+4)>>3

NewPixel(i,2)=(15×Pixel1(i,2)+Pixel2(i,2)+8)>>4

NewPixel(i,3)=(31×Pixel1(i,3)+Pixel2(i,3)+16)>>5

-   -   -   For chroma blocks, the number of blending pixel rows is 1.

NewPixel(i,0)=(26×Pixel1(i,0)+6×Pixel2(i,0)+16)>>5

-   -   If Cost1<=Cost2, then blending mode 2 is used.        -   For luma blocks, the number of blending pixel rows is 2.

NewPixel(i,0)=(15×Pixel1(i,0)+Pixel2(i,0)+8)>>4

NewPixel(i,1)=(31×Pixel1(i,1)+Pixel2(i,1)+16)>>5

-   -   -   For chroma blocks, the number of blending pixel rows/columns            is 1.

NewPixel(i,0)=(15×Pixel1(i,0)+Pixel2(i,0)+8)>>4

-   -   Otherwise, blending mode 3 is used.        -   For luma blocks, the number of blending pixel rows is 4.

NewPixel(i,1)=(7×Pixel1(i,1)+Pixel2(i,1)+4)>>3

NewPixel(i,2)=(15×Pixel1(i,2)+Pixel2(i,2)+8)>>4

NewPixel(i,3)=(31×Pixel1(i,3)+Pixel2(i,3)+16)>>5

-   -   -   For chroma blocks, the number of blending pixel rows is 1.

NewPixel(i,0)=(7×Pixel1(i,0)+Pixel2(i,0)+4)>>3

Intra template matching prediction (IntraTMP) is now described. IntraTMPis a special intra prediction mode that copies the best prediction blockfrom the reconstructed part of the current frame, whose L-shapedtemplate matches the current template. For a predefined search range,the encoder searches for the most similar template to the currenttemplate in a reconstructed part of the current frame and uses thecorresponding block as a prediction block. Video encoder 200 thensignals the usage of this mode, and the same prediction operation isperformed at the decoder side.

FIG. 10 is a conceptual diagram illustrating an example intra templatematching search area. SAD is used as a cost function. The predictionsignal is generated by matching the L-shaped causal neighbor of acurrent block 1000 with another block in a predefined search area inFIG. 10 consisting of:

-   -   R1: current CTU    -   R2: top-left CTU    -   R3: above CTU    -   R4: left CTU

Within each of regions R1, R2, R3, and R4, video decoder 300 searchesfor a reference template that has least SAD with respect to the templateof current block 1000 and uses a block (e.g., matching block 1002)corresponding to the reference template as a prediction block.

The dimensions of all regions (SearchRange_w, SearchRange_h) are setproportional to the block dimension (BlkW, BlkH) to have a fixed numberof SAD comparisons per pixel. That is:

SearchRange_w=5*BlkW

SearchRange_h=5*BlkH

The Intra template matching tool is enabled for CUs with size less thanor equal to 64 in width and height. This maximum CU size for Intratemplate matching may be configurable. The Intra template matchingprediction mode may be signaled at a CU level through a dedicated flagwhen decoder-side intra mode derivation (DIMD) is not used for currentCU.

Intra Block Copy (IBC) with TM-AMVP (IBC-TM-AMVP) and IBC with TM-MRG(IBC-TM-MRG) is now discussed. Template Matching is used in IBC for bothIBC merge mode and IBC AMVP mode, called respectively as IBC-TM-AMVP andIBC-TM-MRG.

In IBC-TM-MRG, the merge list is modified compared to the one used byregular IBC merge mode such that the candidates are selected accordingto a pruning method with a motion distance between the candidates as inthe regular TM merge mode. The ending zero motion fulfillment isreplaced by motion vectors to the left (−W, 0), top (0, −H) and top-left(−W, −H), where W is the width and H the height of the current CU. Inaddition, the selected candidates are refined with the Template Matchingmethod prior to the RDO or decoding process. The IBC-TM-MRG mode hasbeen put in competition with the regular IBC merge mode and a TM-mergeflag is signaled.

In the IBC-TM-AMVP mode, up to 3 candidates are selected from theIBC-TM-MRG merge list. Each of those 3 selected candidates are refinedusing the Template Matching method and sorted according to theirresulting Template Matching cost. Only the 2 first ones are thenconsidered in the motion estimation process.

FIG. 11 is a conceptual diagram illustrating intra block copy referenceregion depending on a current coding CU position. The Template Matchingrefinement for both IBC-TM merge and AMVP modes is quite simple sinceIBC motion vectors are constrained (i) to be integer and (ii) within areference region as shown in FIG. 11 . Specifically, in the example ofFIG. 11 , each small square correspond to a CU. The squares with darkerborders surrounding groups of four CUs may correspond to CTUs. In someexamples, each of the CTUs may be of size 128×128 while each of the CUsmay have sizes of 64×64. Furthermore, FIG. 11 show a current CU 1100 atdifferent locations within a CTU. Shaded CUs are causal for current CU1100. Different CUs are available for IBC depending on the position ofcurrent CU 1100. In FIG. 11 , CUs marked with “X” are unavailable forIBC.

In IBC-TM-MRG mode, all refinements are performed at integer precision,and in IBC-TM-AMVP mode, refinements are performed either at integerprecision or 4-pel precision depending on the AMVR value. Such arefinement accesses only to samples without interpolation. In bothcases, the refined motion vectors and the used template in eachrefinement step must respect the constraint of the reference region.

In the on-going development of ECM common testing software platform,template matching prediction and related coding tools that work relyingon template matching prediction are almost everywhere. Not every one ofthe coding tools has systematic design at high-level syntax to switchtemplate matching prediction and related coding tools on and off. Someof the coding tools may leave the codec with an undefined behavior whena certain template matching related tool is disabled from the bitstream.

If not otherwise stated, a coding tool referred hereafter to as a “TMtool” is a tool from, but not limited to, the template matching relatedcoding tools (e.g., TM-AMVP, TM-MRG, . . . ) as described in thesections of this disclosure related to TM-AMVP and TM-MRG, TM-GPM,TM-CIIP, ARMC, TMCP and non-adjacent merge candidate type reordering,GPM split mode reordering, candidate reordering for regular MMVD andaffine MMVD, MVD sign prediction, reference picture reordering, TM-OBMC,IntraTMP, IBC-TM-AMVP, and IBC-TM-MRG.

High-level flag control for TM tools is now discussed. In accordancewith an example of this disclosure, each TM tool (e.g., TM-TemplateMatching Advanced Motion Vector Prediction (TM-AMVP) and TemplateMatching Merge (TM-MRG), TM-GPM, TM-CIIP, ARMC, TMCP and non-adjacentmerge candidate type reordering, GPM split mode reordering, Candidatereordering for regular MMVD and affine MMVD, MVD sign prediction,reference picture reordering, TM-OBMC, IntraTMP, IBC-TM-AMVP, andIBC-TM-MRG as described elsewhere in this disclosure) may has its ownsequence-, picture-, subpicture-, slice- and/or tile-level flag todetermine whether the respective syntax and decoding/reconstructionprocesses are applied. When the respective flag indicates a TM tool isnot applied, video decoder 300 may either turn off the TM tool orrollback to the original syntax/decoding/reconstruction design,depending on which TM tool is used.

Some TM tools modified the original codec design, and thus rollback maybe required when respective flags are off.

-   -   TM-AMVP: Roll back to VTM that signals AMVP flag and template        matching.    -   GPM split mode reordering: Roll back to VTM which signals GPM        split mode using binary code without context coding.    -   Candidate reordering for regular MMVD and affine MMVD: Roll back        to direction index coding and offset index coding to represent        the motion of a merge candidate.    -   MVD sign prediction: Roll back to VTM to separate the coding for        the sign bits of x- and y-components of a motion vector        difference vector.    -   Reference picture reordering: Roll back to VTM to signal        reference index separately for each reference picture list.

Other TM tools may be new coding feature, and thus can be turned off(i.e., related syntax element no longer present in the bitstream andcorresponding decoding process bypassed) when respective flags are off.

-   -   TM-MRG    -   TM-GPM    -   TM-CIIP    -   ARMC    -   TMVP and Non-adjacent merge candidate type reordering    -   TM-OBMC    -   IntraTMP    -   IBC-TM-AMVP    -   IBC-TM-MRG

In some examples, some TM tools that have similar functionalities canshare the same high-level flags to enable or disable them altogether.

-   -   In some examples, TM-AMVP and IBC-TM-AMVP are both AMVP-related        tools and can share the same high-level flags for switching them        on and off altogether. In other words, a single high-level flag        may switch both TM-AMVP and IBC-TM-AMVP on and off.    -   In some examples, TM-MRG and IBC-TM-MRG are both block-based        merge mode and can share the same high-level flags for switching        them on and off altogether.    -   In some examples, GPM split mode reordering, candidate        reordering for regular MMVD and affine MMVD, MVD sign        prediction, reference picture reordering, ARMC, TMVP and        non-adjacent merge candidate type reordering are TM-based        ordering methods and can share the same high-level flags for        switching them on and off altogether. In addition, MVD sign        prediction may not be included because its template shape may        not be aligned with other TM tools aforementioned in this        example.

In some examples, some TM tools may have dependency that requirescertain functionalities from another TM tool. For example, many toolsrely on the same template samples as ARMC to compute TM cost forreordering. Their high-level flags are supposed to be present inbitstream only when ARMC's high level flag is enabled. It is noted thatwhen a high-level flag of a TM tool is not present in bitstream, thecorresponding TM tool is disabled.

-   -   In some examples, a high-level flag of IBC-TM-AMVP is present        only when the high-level flag of TM-AMVP at the same hierarchy        (e.g., sequence-, picture-, subpicture-, slice- and/or        tile-level) is enabled.    -   In some examples, a high-level flag of IBC-TM-MRG is present        only when the high-level flag of TM-MRG at the same hierarchy        (e.g., sequence-, picture-, subpicture-, slice- and/or        tile-level) is enabled.    -   In some examples, a high-level flag of TM-CIIP is present only        when CIIP is enabled and the high-level flag of TM-MRG at the        same hierarchy (e.g., sequence-, picture-, subpicture-, slice-        and/or tile-level) is enabled.    -   In some examples, a high-level flag of N is present only when        the high-level flag of ARMC at the same hierarchy (e.g.,        sequence-, picture-, subpicture-, slice- and/or tile-level) is        enabled, where N can be, but not limited to, GPM split mode        reordering, candidate reordering for regular MMVD and affine        MMVD, MVD sign prediction, reference picture reordering, TMVP        and non-adjacent merge candidate type reordering.

In some examples, TM tools may be characterized with different levels ofdecoding complexity and thus can be controlled on and off together tooffer configurable coding tool set in restricted decoding environments.Typically, there are two types of MV refinement that template matchingadopts: (1) searching around a given initial motion vector to reduce TMcost and (2) searching within a list of motion vector candidates to findone that reaches lowest TM cost. Two flags at each of the codinghierarchy (e.g., sequence-, picture-, subpicture-, slice- and/ortile-level) may be present in the bitstream to enable and disable TMtools.

The first flag may enable or disable the coding tools listed below:

-   -   TM-AMVP    -   TM-MRG    -   TM-GPM    -   TM-CIIP    -   IntraTMP    -   IBC-TM-AMVP    -   IBC-TM-MRG

The second flag may enable or disable the coding tools listed below:

-   -   ARMC    -   TMVP and non-adjacent merge candidate type reordering    -   GPM split mode reordering    -   Candidate reordering for regular MMVD and affine MMVD    -   MVD sign prediction    -   Reference picture reordering    -   TM-OBMC

In some examples, IntraTMP may not be included from the control of thefirst flag. In some examples, IntraTMP, IBC-TM-AMVP and IBC-TM-MRG arenot included in the list of coding tools controlled by the first flagbecause IntraTMP, IBC-TM-AMVP and IBC-TM-MRG are intra coding tools.

In some examples, a high-level flag (e.g., at sequence-, picture-,subpicture-, slice- and/or tile-level) may be signaled before those ofTM tools to indicate whether TM tools are used. When this flag is on,the high-level flags of TM tools follow in the parsing order after thisnewly introduced high-level flag; otherwise, when this flag is off, allthe high-level flag of TM tools are not present in the bitstream andtheir flag values are set as off.

In some examples, IntraTMP may not be included from the control of thisnew flag. In some examples, IntraTMP, IBC-TM-AMVP and IBC-TM-MRG may notbe included from the control of this new flag. In some examples, thisnew flag, when enabled, also indicates whether the high-level flags ofbilateral-matching based methods (e.g., DMVR and multi-pass DMVR) arepresent in the bitstream.

Thus, in some examples, video encoder 200 may signal a syntax element inthe bitstream. The second syntax element may be a sequence-level syntaxelement, a picture-level syntax element, a slice-level syntax element,or a tile-level syntax element. The second syntax element may indicatewhether the bitstream includes one or more template-matching tool syntaxelements. Based on the syntax element, video encoder 200 may signal oneor more syntax elements in the bitstream indicating whether one or moretemplate-matching tools are enabled. In some such examples, presence ofsyntax elements indicating whether intra template matching prediction(intraTMP), intra block copy template matching with advanced motionvector prediction (IBC-TM-AMVP), and intra block copy template matchingwith merge mode (IBC-TM-AMVP) are enabled is not dependent on the syntaxelement. Similarly, video decoder 300 may obtain a syntax element fromthe bitstream, wherein the second syntax element is a sequence-levelsyntax element, a picture-level syntax element, a slice-level syntaxelement, or a tile-level syntax element. Video decoder 300 maydetermine, based on the syntax element, whether the bitstream includesone or more syntax elements (i.e., template-matching tool syntaxelements) indicating whether one or more template-matching tools areenabled. In some such examples, presence of syntax elements indicatingwhether intra template matching prediction (intraTMP), intra block copytemplate matching with advanced motion vector prediction (IBC-TM-AMVP),and intra block copy template matching with merge mode (IBC-TM-AMVP) areenabled is not dependent on the syntax element.

In another example, when a high-level flag of IBC-TM-MRG is disabled inthe bitstream, the pruning threshold used to determine whether the samemotion vector component (that is either x or y direction) of two motionvectors are similar is set equal to N (where N is a positive integer).When the absolute difference a MV component between two MVs is less thanN, it means the MV motion component of two MVs are similar. If each MVcomponent of the two MVs are similar, video encoder 200 and videodecoder 300 may prune one of the MVs in the construction process of IBCmerge candidate list. Typically, N is set equal to either 1 (which meanstwo MVs are regarded as similar when they are exactly identical to eachother) or 0 (which means similarity-based pruning is disabled).

In another example, the same notion can be applied to IBC-TM-AMVP. Whena high-level flag of IBC-TM-AMVP is disabled in the bitstream, if eachMV component of two MVs is similar, video encoder 200 and video decoder300 may prune one of the MVs in the construction process of IBC AMVPcandidate list. Typically, N is set equal to either 1 or 0.

Thus, in some examples, based on the syntax element indicatingintra-block copy template matching merge mode (IBC-TM-MRG) orintra-block copy template matching advance motion vector prediction(IBC-TM-AMVP) is disabled, video encoder 200 may set a pruning thresholdto a value. Video encoder 200 may prune a first candidate from a listbased on a difference between a motion vector component of the firstcandidate and a motion vector component of a second candidate in thelist being less than the pruning threshold. Video encoder 200 may applythe template-matching tool to generate the prediction block for thecurrent CU comprises applying the template-matching tool to generate theprediction block for the current CU based on a candidate in the list.Similarly, based on a syntax element indicating intra-block copytemplate matching merge mode (IBC-TM-MRG) or intra-block copy templatematching advance motion vector prediction (IBC-TM-AMVP) is disabled,video decoder 300 may set a pruning threshold to a value. Video decoder300 may prune a first candidate from a list based on a differencebetween a motion vector component of the first candidate and a motionvector component of a second candidate in the list being less than thepruning threshold. Video decoder 300 may apply the template-matchingtool to generate the prediction block for the current CU comprisesapplying the template-matching tool to generate the prediction block forthe current CU based on a candidate in the list.

FIG. 12 is a block diagram illustrating an example video encoder 200that may perform the techniques of this disclosure. FIG. 12 is providedfor purposes of explanation and should not be considered limiting of thetechniques as broadly exemplified and described in this disclosure. Forpurposes of explanation, this disclosure describes video encoder 200according to the techniques of VVC (ITU-T H.266, under development), andHEVC (ITU-T H.265). However, the techniques of this disclosure may beperformed by video encoding devices that are configured to other videocoding standards and video coding formats, such as AV1 and successors tothe AV1 video coding format.

In the example of FIG. 12 , video encoder 200 includes video data memory230, mode selection unit 202, residual generation unit 204, transformprocessing unit 206, quantization unit 208, inverse quantization unit210, inverse transform processing unit 212, reconstruction unit 214,filter unit 216, decoded picture buffer (DPB) 218, and entropy encodingunit 220. Any or all of video data memory 230, mode selection unit 202,residual generation unit 204, transform processing unit 206,quantization unit 208, inverse quantization unit 210, inverse transformprocessing unit 212, reconstruction unit 214, filter unit 216, DPB 218,and entropy encoding unit 220 may be implemented in one or moreprocessors or in processing circuitry. For instance, the units of videoencoder 200 may be implemented as one or more circuits or logic elementsas part of hardware circuitry, or as part of a processor, ASIC, or FPGA.Moreover, video encoder 200 may include additional or alternativeprocessors or processing circuitry to perform these and other functions.

Video data memory 230 may store video data to be encoded by thecomponents of video encoder 200. Video encoder 200 may receive the videodata stored in video data memory 230 from, for example, video source 104(FIG. 1 ). DPB 218 may act as a reference picture memory that storesreference video data for use in prediction of subsequent video data byvideo encoder 200. Video data memory 230 and DPB 218 may be formed byany of a variety of memory devices, such as dynamic random access memory(DRAM), including synchronous DRAM (SDRAM), magnetoresistive RAM (MRAM),resistive RAM (RRAM), or other types of memory devices. Video datamemory 230 and DPB 218 may be provided by the same memory device orseparate memory devices. In various examples, video data memory 230 maybe on-chip with other components of video encoder 200, as illustrated,or off-chip relative to those components.

In this disclosure, reference to video data memory 230 should not beinterpreted as being limited to memory internal to video encoder 200,unless specifically described as such, or memory external to videoencoder 200, unless specifically described as such. Rather, reference tovideo data memory 230 should be understood as reference memory thatstores video data that video encoder 200 receives for encoding (e.g.,video data for a current block that is to be encoded). Memory 106 ofFIG. 1 may also provide temporary storage of outputs from the variousunits of video encoder 200.

The various units of FIG. 12 are illustrated to assist withunderstanding the operations performed by video encoder 200. The unitsmay be implemented as fixed-function circuits, programmable circuits, ora combination thereof. Fixed-function circuits refer to circuits thatprovide particular functionality, and are preset on the operations thatcan be performed. Programmable circuits refer to circuits that can beprogrammed to perform various tasks, and provide flexible functionalityin the operations that can be performed. For instance, programmablecircuits may execute software or firmware that cause the programmablecircuits to operate in the manner defined by instructions of thesoftware or firmware. Fixed-function circuits may execute softwareinstructions (e.g., to receive parameters or output parameters), but thetypes of operations that the fixed-function circuits perform aregenerally immutable. In some examples, one or more of the units may bedistinct circuit blocks (fixed-function or programmable), and in someexamples, one or more of the units may be integrated circuits.

Video encoder 200 may include arithmetic logic units (ALUs), elementaryfunction units (EFUs), digital circuits, analog circuits, and/orprogrammable cores, formed from programmable circuits. In examples wherethe operations of video encoder 200 are performed using softwareexecuted by the programmable circuits, memory 106 (FIG. 1 ) may storethe instructions (e.g., object code) of the software that video encoder200 receives and executes, or another memory within video encoder 200(not shown) may store such instructions.

Video data memory 230 is configured to store received video data. Videoencoder 200 may retrieve a picture of the video data from video datamemory 230 and provide the video data to residual generation unit 204and mode selection unit 202. Video data in video data memory 230 may beraw video data that is to be encoded.

Mode selection unit 202 includes a motion estimation unit 222, a motioncompensation unit 224, and an intra prediction unit 226. Mode selectionunit 202 may include additional functional units to perform videoprediction in accordance with other prediction modes. As examples, modeselection unit 202 may include a palette unit, an intra-block copy unit(which may be part of motion estimation unit 222 and/or motioncompensation unit 224), an affine unit, a linear model (LM) unit, or thelike. In the example of FIG. 12 , motion estimation unit 222 includes atemplate matching unit 228 may implement template-matching coding tools,such as TM-AMVP, GPM split mode reordering, candidate reordering forregular MMVD and affine MMVD, MVD sign prediction, reference picturereordering, template-matching merge mode, template-matching GPM,template-matching CIIP, adaptive re-ordering of merge candidates, TMVPand non-adjacent merge candidate type reordering, TM-OBMC, IntraTMP,IBC-TM-AMVP, and IBC-TM-AMVP. In accordance with techniques of thisdisclosure, motion estimation unit 222 may signal one or more syntaxelements to indicate whether one or more of the template-matching toolsare enabled.

Mode selection unit 202 generally coordinates multiple encoding passesto test combinations of encoding parameters and resultingrate-distortion values for such combinations. The encoding parametersmay include partitioning of CTUs into CUs, prediction modes for the CUs,transform types for residual data of the CUs, quantization parametersfor residual data of the CUs, and so on. Mode selection unit 202 mayultimately select the combination of encoding parameters havingrate-distortion values that are better than the other testedcombinations.

Video encoder 200 may partition a picture retrieved from video datamemory 230 into a series of CTUs, and encapsulate one or more CTUswithin a slice. Mode selection unit 202 may partition a CTU of thepicture in accordance with a tree structure, such as the MTT structure,QTBT structure. superblock structure, or the quad-tree structuredescribed above. As described above, video encoder 200 may form one ormore CUs from partitioning a CTU according to the tree structure. Such aCU may also be referred to generally as a “video block” or “block.”

In general, mode selection unit 202 also controls the components thereof(e.g., motion estimation unit 222, motion compensation unit 224, andintra prediction unit 226) to generate a prediction block for a currentblock (e.g., a current CU, or in HEVC, the overlapping portion of a PUand a TU). For inter-prediction of a current block, motion estimationunit 222 may perform a motion search to identify one or more closelymatching reference blocks in one or more reference pictures (e.g., oneor more previously coded pictures stored in DPB 218). In particular,motion estimation unit 222 may calculate a value representative of howsimilar a potential reference block is to the current block, e.g.,according to sum of absolute difference (SAD), sum of squareddifferences (SSD), mean absolute difference (MAD), mean squareddifferences (MSD), or the like. Motion estimation unit 222 may generallyperform these calculations using sample-by-sample differences betweenthe current block and the reference block being considered. Motionestimation unit 222 may identify a reference block having a lowest valueresulting from these calculations, indicating a reference block thatmost closely matches the current block.

Motion estimation unit 222 may form one or more motion vectors (MVs)that define the positions of the reference blocks in the referencepictures relative to the position of the current block in a currentpicture. Motion estimation unit 222 may then provide the motion vectorsto motion compensation unit 224. For example, for uni-directionalinter-prediction, motion estimation unit 222 may provide a single motionvector, whereas for bi-directional inter-prediction, motion estimationunit 222 may provide two motion vectors. Motion compensation unit 224may then generate a prediction block using the motion vectors. Forexample, motion compensation unit 224 may retrieve data of the referenceblock using the motion vector. As another example, if the motion vectorhas fractional sample precision, motion compensation unit 224 mayinterpolate values for the prediction block according to one or moreinterpolation filters. Moreover, for bi-directional inter-prediction,motion compensation unit 224 may retrieve data for two reference blocksidentified by respective motion vectors and combine the retrieved data,e.g., through sample-by-sample averaging or weighted averaging.

When operating according to the AV1 video coding format, motionestimation unit 222 and motion compensation unit 224 may be configuredto encode coding blocks of video data (e.g., both luma and chroma codingblocks) using translational motion compensation, affine motioncompensation, overlapped block motion compensation (OBMC), and/orcompound inter-intra prediction.

As another example, for intra-prediction, or intra-prediction coding,intra prediction unit 226 may generate the prediction block from samplesneighboring the current block. For example, for directional modes, intraprediction unit 226 may generally mathematically combine values ofneighboring samples and populate these calculated values in the defineddirection across the current block to produce the prediction block. Asanother example, for DC mode, intra prediction unit 226 may calculate anaverage of the neighboring samples to the current block and generate theprediction block to include this resulting average for each sample ofthe prediction block.

When operating according to the AV1 video coding format, intraprediction unit 226 may be configured to encode coding blocks of videodata (e.g., both luma and chroma coding blocks) using directional intraprediction, non-directional intra prediction, recursive filter intraprediction, chroma-from-luma (CFL) prediction, intra block copy (IBC),and/or color palette mode. Mode selection unit 202 may includeadditional functional units to perform video prediction in accordancewith other prediction modes.

Mode selection unit 202 provides the prediction block to residualgeneration unit 204. Residual generation unit 204 receives a raw,unencoded version of the current block from video data memory 230 andthe prediction block from mode selection unit 202. Residual generationunit 204 calculates sample-by-sample differences between the currentblock and the prediction block. The resulting sample-by-sampledifferences define a residual block for the current block. In someexamples, residual generation unit 204 may also determine differencesbetween sample values in the residual block to generate a residual blockusing residual differential pulse code modulation (RDPCM). In someexamples, residual generation unit 204 may be formed using one or moresubtractor circuits that perform binary subtraction.

In examples where mode selection unit 202 partitions CUs into PUs, eachPU may be associated with a luma prediction unit and correspondingchroma prediction units. Video encoder 200 and video decoder 300 maysupport PUs having various sizes. As indicated above, the size of a CUmay refer to the size of the luma coding block of the CU and the size ofa PU may refer to the size of a luma prediction unit of the PU. Assumingthat the size of a particular CU is 2N×2N, video encoder 200 may supportPU sizes of 2N×2N or N×N for intra prediction, and symmetric PU sizes of2N×2N, 2N×N, N×2N, N×N, or similar for inter prediction. Video encoder200 and video decoder 300 may also support asymmetric partitioning forPU sizes of 2N×nU, 2N×nD, nL×2N, and nR×2N for inter prediction.

In examples where mode selection unit 202 does not further partition aCU into PUs, each CU may be associated with a luma coding block andcorresponding chroma coding blocks. As above, the size of a CU may referto the size of the luma coding block of the CU. The video encoder 200and video decoder 300 may support CU sizes of 2N×2N, 2N×N, or N×2N.

For other video coding techniques such as an intra-block copy modecoding, an affine-mode coding, and linear model (LM) mode coding, assome examples, mode selection unit 202, via respective units associatedwith the coding techniques, generates a prediction block for the currentblock being encoded. In some examples, such as palette mode coding, modeselection unit 202 may not generate a prediction block, and insteadgenerate syntax elements that indicate the manner in which toreconstruct the block based on a selected palette. In such modes, modeselection unit 202 may provide these syntax elements to entropy encodingunit 220 to be encoded.

As described above, residual generation unit 204 receives the video datafor the current block and the corresponding prediction block. Residualgeneration unit 204 then generates a residual block for the currentblock. To generate the residual block, residual generation unit 204calculates sample-by-sample differences between the prediction block andthe current block.

Transform processing unit 206 applies one or more transforms to theresidual block to generate a block of transform coefficients (referredto herein as a “transform coefficient block”). Transform processing unit206 may apply various transforms to a residual block to form thetransform coefficient block. For example, transform processing unit 206may apply a discrete cosine transform (DCT), a directional transform, aKarhunen-Loeve transform (KLT), or a conceptually similar transform to aresidual block. In some examples, transform processing unit 206 mayperform multiple transforms to a residual block, e.g., a primarytransform and a secondary transform, such as a rotational transform. Insome examples, transform processing unit 206 does not apply transformsto a residual block.

When operating according to AV1, transform processing unit 206 may applyone or more transforms to the residual block to generate a block oftransform coefficients (referred to herein as a “transform coefficientblock”). Transform processing unit 206 may apply various transforms to aresidual block to form the transform coefficient block. For example,transform processing unit 206 may apply a horizontal/vertical transformcombination that may include a discrete cosine transform (DCT), anasymmetric discrete sine transform (ADST), a flipped ADST (e.g., an ADSTin reverse order), and an identity transform (IDTX). When using anidentity transform, the transform is skipped in one of the vertical orhorizontal directions. In some examples, transform processing may beskipped.

Quantization unit 208 may quantize the transform coefficients in atransform coefficient block, to produce a quantized transformcoefficient block. Quantization unit 208 may quantize transformcoefficients of a transform coefficient block according to aquantization parameter (QP) value associated with the current block.Video encoder 200 (e.g., via mode selection unit 202) may adjust thedegree of quantization applied to the transform coefficient blocksassociated with the current block by adjusting the QP value associatedwith the CU. Quantization may introduce loss of information, and thus,quantized transform coefficients may have lower precision than theoriginal transform coefficients produced by transform processing unit206.

Inverse quantization unit 210 and inverse transform processing unit 212may apply inverse quantization and inverse transforms to a quantizedtransform coefficient block, respectively, to reconstruct a residualblock from the transform coefficient block. Reconstruction unit 214 mayproduce a reconstructed block corresponding to the current block (albeitpotentially with some degree of distortion) based on the reconstructedresidual block and a prediction block generated by mode selection unit202. For example, reconstruction unit 214 may add samples of thereconstructed residual block to corresponding samples from theprediction block generated by mode selection unit 202 to produce thereconstructed block.

Filter unit 216 may perform one or more filter operations onreconstructed blocks. For example, filter unit 216 may performdeblocking operations to reduce blockiness artifacts along edges of CUs.Operations of filter unit 216 may be skipped, in some examples.

When operating according to AV1, filter unit 216 may perform one or morefilter operations on reconstructed blocks. For example, filter unit 216may perform deblocking operations to reduce blockiness artifacts alongedges of CUs. In other examples, filter unit 216 may apply a constraineddirectional enhancement filter (CDEF), which may be applied afterdeblocking, and may include the application of non-separable,non-linear, low-pass directional filters based on estimated edgedirections. Filter unit 216 may also include a loop restoration filter,which is applied after CDEF, and may include a separable symmetricnormalized Wiener filter or a dual self-guided filter.

Video encoder 200 stores reconstructed blocks in DPB 218. For instance,in examples where operations of filter unit 216 are not performed,reconstruction unit 214 may store reconstructed blocks to DPB 218. Inexamples where operations of filter unit 216 are performed, filter unit216 may store the filtered reconstructed blocks to DPB 218. Motionestimation unit 222 and motion compensation unit 224 may retrieve areference picture from DPB 218, formed from the reconstructed (andpotentially filtered) blocks, to inter-predict blocks of subsequentlyencoded pictures. In addition, intra prediction unit 226 may usereconstructed blocks in DPB 218 of a current picture to intra-predictother blocks in the current picture.

In general, entropy encoding unit 220 may entropy encode syntax elementsreceived from other functional components of video encoder 200. Forexample, entropy encoding unit 220 may entropy encode quantizedtransform coefficient blocks from quantization unit 208. As anotherexample, entropy encoding unit 220 may entropy encode prediction syntaxelements (e.g., motion information for inter-prediction or intra-modeinformation for intra-prediction) from mode selection unit 202. Entropyencoding unit 220 may perform one or more entropy encoding operations onthe syntax elements, which are another example of video data, togenerate entropy-encoded data. For example, entropy encoding unit 220may perform a context-adaptive variable length coding (CAVLC) operation,a CABAC operation, a variable-to-variable (V2V) length coding operation,a syntax-based context-adaptive binary arithmetic coding (SBAC)operation, a Probability Interval Partitioning Entropy (PIPE) codingoperation, an Exponential-Golomb encoding operation, or another type ofentropy encoding operation on the data. In some examples, entropyencoding unit 220 may operate in bypass mode where syntax elements arenot entropy encoded.

Video encoder 200 may output a bitstream that includes the entropyencoded syntax elements needed to reconstruct blocks of a slice orpicture. In particular, entropy encoding unit 220 may output thebitstream.

In accordance with AV1, entropy encoding unit 220 may be configured as asymbol-to-symbol adaptive multi-symbol arithmetic coder. A syntaxelement in AV1 includes an alphabet of N elements, and a context (e.g.,probability model) includes a set of N probabilities. Entropy encodingunit 220 may store the probabilities as n-bit (e.g., 15-bit) cumulativedistribution functions (CDFs). Entropy encoding unit 220 may performrecursive scaling, with an update factor based on the alphabet size, toupdate the contexts.

The operations described above are described with respect to a block.Such description should be understood as being operations for a lumacoding block and/or chroma coding blocks. As described above, in someexamples, the luma coding block and chroma coding blocks are luma andchroma components of a CU. In some examples, the luma coding block andthe chroma coding blocks are luma and chroma components of a PU.

In some examples, operations performed with respect to a luma codingblock need not be repeated for the chroma coding blocks. As one example,operations to identify a motion vector (MV) and reference picture for aluma coding block need not be repeated for identifying a MV andreference picture for the chroma blocks. Rather, the MV for the lumacoding block may be scaled to determine the MV for the chroma blocks,and the reference picture may be the same. As another example, theintra-prediction process may be the same for the luma coding block andthe chroma coding blocks.

Video encoder 200 represents an example of a device configured to encodevideo data including a memory configured to store video data, and one ormore processors implemented in circuitry and configured to signal asyntax element in a bitstream that includes an encoded representation ofthe video data, a syntax element. The syntax element may be asequence-level syntax element, a picture-level syntax element, aslice-level syntax element, or a tile-level syntax element. The syntaxelement indicates whether a template-matching tool is enabled.Furthermore, the one or more processors may be configured to, based onthe template-matching tool being enabled, apply the template-matchingtool to generate a prediction block for a current CU of the video data.The one or more processors may encode the current CU based on theprediction block for the current CU.

FIG. 13 is a block diagram illustrating an example video decoder 300that may perform the techniques of this disclosure. FIG. 13 is providedfor purposes of explanation and is not limiting on the techniques asbroadly exemplified and described in this disclosure. For purposes ofexplanation, this disclosure describes video decoder 300 according tothe techniques of VVC (ITU-T H.266, under development), and HEVC (ITU-TH.265). However, the techniques of this disclosure may be performed byvideo coding devices that are configured to other video codingstandards.

In the example of FIG. 13 , video decoder 300 includes coded picturebuffer (CPB) memory 320, entropy decoding unit 302, predictionprocessing unit 304, inverse quantization unit 306, inverse transformprocessing unit 308, reconstruction unit 310, filter unit 312, anddecoded picture buffer (DPB) 314. Any or all of CPB memory 320, entropydecoding unit 302, prediction processing unit 304, inverse quantizationunit 306, inverse transform processing unit 308, reconstruction unit310, filter unit 312, and DPB 314 may be implemented in one or moreprocessors or in processing circuitry. For instance, the units of videodecoder 300 may be implemented as one or more circuits or logic elementsas part of hardware circuitry, or as part of a processor, ASIC, or FPGA.Moreover, video decoder 300 may include additional or alternativeprocessors or processing circuitry to perform these and other functions.

Prediction processing unit 304 includes motion compensation unit 316 andintra prediction unit 318. Prediction processing unit 304 may includeadditional units to perform prediction in accordance with otherprediction modes. As examples, prediction processing unit 304 mayinclude a palette unit, an intra-block copy unit (which may form part ofmotion compensation unit 316), an affine unit, a linear model (LM) unit,or the like. In other examples, video decoder 300 may include more,fewer, or different functional components.

When operating according to AV1, motion compensation unit 316 may beconfigured to decode coding blocks of video data (e.g., both luma andchroma coding blocks) using translational motion compensation, affinemotion compensation, OBMC, and/or compound inter-intra prediction, asdescribed above. Intra prediction unit 318 may be configured to decodecoding blocks of video data (e.g., both luma and chroma coding blocks)using directional intra prediction, non-directional intra prediction,recursive filter intra prediction, CFL, intra block copy (IBC), and/orcolor palette mode, as described above.

In the example of FIG. 13 , motion compensation unit 316 includes atemplate matching unit 322 that implements template-matching codingtools, such as TM-AMVP, GPM split mode reordering, candidate reorderingfor regular MMVD and affine MMVD, MVD sign prediction, reference picturereordering, template-matching merge mode, template-matching GPM,template-matching CIIP, adaptive re-ordering of merge candidates, TMVPand non-adjacent merge candidate type reordering, TM-OBMC, IntraTMP,IBC-TM-AMVP, and IBC-TM-AMVP. In accordance with techniques of thisdisclosure, template matching unit 322 may obtain a syntax element froma bitstream. Template matching unit 322 may determine, based on thesyntax element, that a template-matching tool is enabled, apply thetemplate-matching tool to generate a prediction block for a current CU.

CPB memory 320 may store video data, such as an encoded video bitstream,to be decoded by the components of video decoder 300. The video datastored in CPB memory 320 may be obtained, for example, fromcomputer-readable medium 110 (FIG. 1 ). CPB memory 320 may include a CPBthat stores encoded video data (e.g., syntax elements) from an encodedvideo bitstream. Also, CPB memory 320 may store video data other thansyntax elements of a coded picture, such as temporary data representingoutputs from the various units of video decoder 300. DPB 314 generallystores decoded pictures, which video decoder 300 may output and/or useas reference video data when decoding subsequent data or pictures of theencoded video bitstream. CPB memory 320 and DPB 314 may be formed by anyof a variety of memory devices, such as DRAM, including SDRAM, MRAM,RRAM, or other types of memory devices. CPB memory 320 and DPB 314 maybe provided by the same memory device or separate memory devices. Invarious examples, CPB memory 320 may be on-chip with other components ofvideo decoder 300, or off-chip relative to those components.

Additionally or alternatively, in some examples, video decoder 300 mayretrieve coded video data from memory 120 (FIG. 1 ). That is, memory 120may store data as discussed above with CPB memory 320. Likewise, memory120 may store instructions to be executed by video decoder 300, whensome or all of the functionality of video decoder 300 is implemented insoftware to be executed by processing circuitry of video decoder 300.

The various units shown in FIG. 13 are illustrated to assist withunderstanding the operations performed by video decoder 300. The unitsmay be implemented as fixed-function circuits, programmable circuits, ora combination thereof. Similar to FIG. 12 , fixed-function circuitsrefer to circuits that provide particular functionality, and are preseton the operations that can be performed. Programmable circuits refer tocircuits that can be programmed to perform various tasks, and provideflexible functionality in the operations that can be performed. Forinstance, programmable circuits may execute software or firmware thatcause the programmable circuits to operate in the manner defined byinstructions of the software or firmware. Fixed-function circuits mayexecute software instructions (e.g., to receive parameters or outputparameters), but the types of operations that the fixed-functioncircuits perform are generally immutable. In some examples, one or moreof the units may be distinct circuit blocks (fixed-function orprogrammable), and in some examples, one or more of the units may beintegrated circuits.

Video decoder 300 may include ALUs, EFUs, digital circuits, analogcircuits, and/or programmable cores formed from programmable circuits.In examples where the operations of video decoder 300 are performed bysoftware executing on the programmable circuits, on-chip or off-chipmemory may store instructions (e.g., object code) of the software thatvideo decoder 300 receives and executes.

Entropy decoding unit 302 may receive encoded video data from the CPBand entropy decode the video data to reproduce syntax elements.Prediction processing unit 304, inverse quantization unit 306, inversetransform processing unit 308, reconstruction unit 310, and filter unit312 may generate decoded video data based on the syntax elementsextracted from the bitstream.

In general, video decoder 300 reconstructs a picture on a block-by-blockbasis. Video decoder 300 may perform a reconstruction operation on eachblock individually (where the block currently being reconstructed, i.e.,decoded, may be referred to as a “current block”).

Entropy decoding unit 302 may entropy decode syntax elements definingquantized transform coefficients of a quantized transform coefficientblock, as well as transform information, such as a quantizationparameter (QP) and/or transform mode indication(s). Inverse quantizationunit 306 may use the QP associated with the quantized transformcoefficient block to determine a degree of quantization and, likewise, adegree of inverse quantization for inverse quantization unit 306 toapply. Inverse quantization unit 306 may, for example, perform a bitwiseleft-shift operation to inverse quantize the quantized transformcoefficients. Inverse quantization unit 306 may thereby form a transformcoefficient block including transform coefficients.

After inverse quantization unit 306 forms the transform coefficientblock, inverse transform processing unit 308 may apply one or moreinverse transforms to the transform coefficient block to generate aresidual block associated with the current block. For example, inversetransform processing unit 308 may apply an inverse DCT, an inverseinteger transform, an inverse Karhunen-Loeve transform (KLT), an inverserotational transform, an inverse directional transform, or anotherinverse transform to the transform coefficient block.

Furthermore, prediction processing unit 304 generates a prediction blockaccording to prediction information syntax elements that were entropydecoded by entropy decoding unit 302. For example, if the predictioninformation syntax elements indicate that the current block isinter-predicted, motion compensation unit 316 may generate theprediction block. In this case, the prediction information syntaxelements may indicate a reference picture in DPB 314 from which toretrieve a reference block, as well as a motion vector identifying alocation of the reference block in the reference picture relative to thelocation of the current block in the current picture. Motioncompensation unit 316 may generally perform the inter-prediction processin a manner that is substantially similar to that described with respectto motion compensation unit 224 (FIG. 12 ).

As another example, if the prediction information syntax elementsindicate that the current block is intra-predicted, intra predictionunit 318 may generate the prediction block according to anintra-prediction mode indicated by the prediction information syntaxelements. Again, intra prediction unit 318 may generally perform theintra-prediction process in a manner that is substantially similar tothat described with respect to intra prediction unit 226 (FIG. 12 ).Intra prediction unit 318 may retrieve data of neighboring samples tothe current block from DPB 314.

Reconstruction unit 310 may reconstruct the current block using theprediction block and the residual block. For example, reconstructionunit 310 may add samples of the residual block to corresponding samplesof the prediction block to reconstruct the current block.

Filter unit 312 may perform one or more filter operations onreconstructed blocks. For example, filter unit 312 may performdeblocking operations to reduce blockiness artifacts along edges of thereconstructed blocks. Operations of filter unit 312 are not necessarilyperformed in all examples.

Video decoder 300 may store the reconstructed blocks in DPB 314. Forinstance, in examples where operations of filter unit 312 are notperformed, reconstruction unit 310 may store reconstructed blocks to DPB314. In examples where operations of filter unit 312 are performed,filter unit 312 may store the filtered reconstructed blocks to DPB 314.As discussed above, DPB 314 may provide reference information, such assamples of a current picture for intra-prediction and previously decodedpictures for subsequent motion compensation, to prediction processingunit 304. Moreover, video decoder 300 may output decoded pictures (e.g.,decoded video) from DPB 314 for subsequent presentation on a displaydevice, such as display device 118 of FIG. 1 .

In this manner, video decoder 300 represents an example of a videodecoding device including a memory configured to store video data, andone or more processing units implemented in circuitry and configured toobtain a syntax element from a bitstream that includes an encodedrepresentation of the video data. The syntax element may be asequence-level syntax element, a picture-level syntax element, aslice-level syntax element, or a tile-level syntax element. The one ormore processors may determine, based on the syntax element, whether atemplate-matching tool is enabled. Based on the template-matching toolbeing enabled, the one or more processors may apply thetemplate-matching tool to generate a prediction block for a current CUof the video data. The one or more processors may reconstruct thecurrent CU based on the prediction block for the current CU.

FIG. 14 is a flowchart illustrating an example method for encoding acurrent block in accordance with the techniques of this disclosure. Thecurrent block may comprise a current CU. Although described with respectto video encoder 200 (FIGS. 1 and 12 ), it should be understood thatother devices may be configured to perform a method similar to that ofFIG. 14 .

In this example, video encoder 200 initially predicts the current block(1400). For example, video encoder 200 may form a prediction block forthe current block. In some examples, video encoder 200 (e.g., templatematching unit 228 of video encoder 200) may form the prediction blockusing a template-matching coding tool. Video encoder 200 may signal oneor more high-level syntax elements to indicate which, if any,template-matching coding tools are enabled.

Video encoder 200 may calculate a residual block for the current block(1402). To calculate the residual block, video encoder 200 may calculatea difference between the original, unencoded block and the predictionblock for the current block. Video encoder 200 may then transform theresidual block and quantize transform coefficients of the residual block(1404). Next, video encoder 200 may scan the quantized transformcoefficients of the residual block (1406). During the scan, or followingthe scan, video encoder 200 may entropy encode the transformcoefficients (1408). For example, video encoder 200 may encode thetransform coefficients using CAVLC or CABAC. Video encoder 200 may thenoutput the entropy encoded data of the block (1410).

FIG. 15 is a flowchart illustrating an example method for decoding acurrent block of video data in accordance with the techniques of thisdisclosure. The current block may comprise a current CU. Althoughdescribed with respect to video decoder 300 (FIGS. 1 and 13 ), it shouldbe understood that other devices may be configured to perform a methodsimilar to that of FIG. 15 .

Video decoder 300 may receive entropy encoded data for the currentblock, such as entropy encoded prediction information and entropyencoded data for transform coefficients of a residual blockcorresponding to the current block (1500). Video decoder 300 may entropydecode the entropy encoded data to determine prediction information forthe current block and to reproduce transform coefficients of theresidual block (1502).

Video decoder 300 may predict the current block (1504), e.g., using anintra- or inter-prediction mode as indicated by the predictioninformation for the current block, to calculate a prediction block forthe current block. In some examples, the syntax elements may include ahigh-level syntax element that indicates whether one or moretemplate-matching coding tools are enabled. Based at least in part ondetermining that a template-matching coding tool is enabled, templatematching unit 322 may apply the template-matching coding tool togenerate a prediction block for the current block. Video decoder 300 mayinverse scan the reproduced transform coefficients (1506), to create ablock of quantized transform coefficients. Video decoder 300 may theninverse quantize the transform coefficients and apply an inversetransform to the transform coefficients to produce a residual block(1508). Video decoder 300 may ultimately decode the current block bycombining the prediction block and the residual block (1510).

FIG. 16 is a flowchart illustrating an example operation of videoencoder 200 in accordance with the techniques of this disclosure. In theexample of FIG. 16 , video encoder 200 may signal, in a bitstream thatincludes an encoded representation of the video data, a syntax elementthat indicates whether a template-matching tool is enabled (1600). Thetemplate-matching tool may be one of: TM-AMVP, GPM split modereordering, candidate reordering for regular MMVD and affine MMVD, MVDsign prediction, reference picture reordering, template-matching mergemode, template-matching GPM, template-matching CIIP, adaptivere-ordering of merge candidates, TMVP and non-adjacent merge candidatetype reordering, TM-OBMC, IntraTMP, IBC-TM-AMVP, or IBC-TM-AMVP.

Based on the template-matching tool being enabled, template matchingunit 228 of video encoder 200 may apply the template-matching tool togenerate a prediction block for a current CU of the video data (1602).Template matching unit 228 may generate the prediction block using thetemplate-matching tool as described elsewhere in this disclosure.

Video encoder 200 may encode the current CU based on the predictionblock for the current CU (1604). For example, residual generation unit204 may generate residual data based on the prediction block andoriginal samples of the current CU. Transform processing unit 206 mayapply one or more transforms to the residual data to generate one ormore transform blocks. Quantization unit 208 may quantize transformcoefficients of the one or more transform blocks. Entropy encoding unit220 may apply entropy encoding to syntax elements representing thequantized transform coefficients.

In some examples, the template-matching tool is a firsttemplate-matching tool, the syntax element is a first syntax element,and video encoder 200 may signal a second syntax element that indicatesthat indicates whether a second template-matching tool is enabled. Ifso, template matching unit 228 may use the second template-matching toolfor generating a prediction block for a different CU. For example, thefirst template-matching tool may be template-matching merge mode and thesecond template-matching tool is template-matching CIIP mode. In otherexample, the first template-matching tool is ARMC and the secondtemplate-matching tool is one of: GPM split mode reordering, candidatereordering for regular MMVD and affine MMVD, MVD sign prediction,reference picture reordering, TMVP, or non-adjacent merge candidate typereordering.

FIG. 17 is a flowchart illustrating an example operation of videodecoder 300 in accordance with the techniques of this disclosure. In theexample of FIG. 17 , video decoder 300 may obtain a syntax element froma bitstream that includes an encoded representation of the video data(1700).

Video decoder 300 may determine, based on the syntax element, that atemplate-matching tool is enabled (1702). The template-matching tool maybe one of: TM-AMVP, GPM split mode reordering, candidate reordering forregular MMVD and affine MMVD, MVD sign prediction, reference picturereordering, template-matching merge mode, template-matching GPM,template-matching CIIP, adaptive re-ordering of merge candidates, TMVPand non-adjacent merge candidate type reordering, TM-OBMC, IntraTMP,IBC-TM-AMVP, or IBC-TM-AMVP.

Based on the template-matching tool being enabled, template matchingunit 322 of video decoder 300 may apply the template-matching tool togenerate a prediction block for a current CU of the video data (1704).Template matching unit 322 may generate the prediction block using thetemplate-matching tool as described elsewhere in this disclosure.

Reconstruction unit 310 of video decoder 300 may reconstruct the currentCU based on the prediction block for the current CU (1706). For example,reconstruction unit 310 may add samples of the prediction block tocorresponding samples of residual data generated by inverse transformprocessing unit 308.

In some examples, the template-matching tool is a firsttemplate-matching tool, the syntax element is a first syntax element,and template matching unit 322 may determine, based on the first syntaxelement, whether the bitstream includes a syntax element that indicateswhether a second template-matching tool is enabled. If so, the templatematching unit 322 may use the second template-matching tool forgenerating a prediction block for a different CU. For example, the firsttemplate-matching tool may be template-matching merge mode and thesecond template-matching tool is template-matching CIIP mode. In otherexample, the first template-matching tool is ARMC and the secondtemplate-matching tool is one of: GPM split mode reordering, candidatereordering for regular MMVD and affine MMVD, MVD sign prediction,reference picture reordering, TMVP and non-adjacent merge candidate typereordering.

The following is a non-limiting list of clauses according to techniquesof this disclosure.

Clause 1A: A method of decoding video data includes obtaining a syntaxelement from a bitstream that includes an encoded representation of thevideo data; determining, based on the syntax element, that atemplate-matching tool is enabled; based on the template-matching toolbeing enabled, applying the template-matching tool to generate aprediction block for a current coding unit (CU) of the video data; andreconstructing the current CU based on the prediction block for thecurrent CU.

Clause 2A: The method of clause 1A, wherein the template-matching toolis one of: template-matching advanced motion vector prediction(TM-AMVP), geometric partitioning mode (GPM) split mode reordering,candidate reordering for regular merge mode with motion vectordifference (MMVD) and affine MMVD, motion vector difference (MVD) signprediction, reference picture reordering, template-matching merge mode,template-matching GPM, template-matching combined inter-intra prediction(CIIP), adaptive re-ordering of merge candidates, temporal motion vectorprediction (TMVP) and non-adjacent merge candidate type reordering,template-matching overlapped block motion compensation (TM-OBMC), intratemplate matching prediction (IntraTMP), intra-block copy-templatematching-advanced motion vector prediction (IBC-TM-AMVP), or intra-blockcopy-template matching-merge (IBC-TM-AMVP).

Clause 3A: The method of any of clauses 1A-2A, wherein: thetemplate-matching tool is a first template-matching tool, and the methodfurther comprises determining, based on the syntax element, whether asecond template-matching tool is enabled.

Clause 4A: The method of any of clauses 1A-3A, wherein: thetemplate-matching tool is a first template-matching tool, the syntaxelement is a first syntax element, and the method further comprisesdetermining, based on the first syntax element, whether the bitstreamincludes a syntax element that indicates whether a secondtemplate-matching tool is enabled.

Clause 5A: The method of clause 1A, wherein: the syntax element is afirst syntax element, wherein the first syntax element indicates whethera first set of one or more template-matching tools are enabled, themethod further comprises obtaining a second syntax element from thebitstream, wherein the second syntax element indicates whether a secondset of one or more template-matching tools are enabled, the first set oftemplate-matching tools involve searching an area around an initialmotion vector, and the second set of template-matching tools involvesearching within a list of motion vector candidates.

Clause 6A: The method of any of clauses 1A-5A, wherein: the syntaxelement is a first syntax element, the method further comprises:obtaining a second syntax element from the bitstream, wherein the syntaxelement is a sequence-level syntax element, a picture-level syntaxelement, a slice-level syntax element, or a tile-level syntax element;and determining, based on the second syntax element, whether thebitstream includes syntax elements indicating whether template-matchingtools are enabled.

Clause 7A: The method of any of clauses 1A-6A, wherein: the methodfurther comprises: based on the syntax element indicating intra-blockcopy template matching merge mode (IBC-TM-MRG) or intra-block copytemplate matching advance motion vector prediction (IBC-TM-AMVP) isdisabled, setting a pruning threshold to a value; and pruning a firstcandidate from a list based on a difference between a motion vectorcomponent of the first candidate and a motion vector component of asecond candidate in the list being less than the pruning threshold, andapplying the template-matching tool to generate the prediction block forthe current CU comprises applying the template-matching tool to generatethe prediction block for the current CU based on a candidate in thelist.

Clause 8A: The method of any of clauses 1A-7A, wherein the syntaxelement is a sequence-level syntax element, a picture-level syntaxelement, a slice-level syntax element, or a tile-level syntax element.

Clause 9A: A method of encoding video data includes signaling a syntaxelement in a bitstream that includes an encoded representation of thevideo data, a syntax element; based on the template-matching tool beingenabled, applying the template-matching tool to generate a predictionblock for a current coding unit (CU) of the video data; and encoding thecurrent CU based on the prediction block for the current CU.

Clause 10A: The method of clause 9A, wherein the template-matching toolis one of: template-matching advanced motion vector prediction(TM-AMVP), geometric partitioning mode (GPM) split mode reordering,candidate reordering for regular merge mode with motion vectordifference (MMVD) and affine MMVD, motion vector difference (MVD) signprediction, reference picture reordering, template-matching merge mode,template-matching GPM, template-matching combined inter-intra prediction(CIIP), adaptive re-ordering of merge candidates, temporal motion vectorprediction (TMVP) and non-adjacent merge candidate type reordering,template-matching overlapped block motion compensation (TM-OBMC), intratemplate matching prediction (IntraTMP), intra-block copy-templatematching-advanced motion vector prediction (IBC-TM-AMVP), or intra-blockcopy-template matching-merge (IBC-TM-AMVP).

Clause 11A: The method of any of clauses 9A-10A, wherein: thetemplate-matching tool is a first template-matching tool, and the syntaxelement also indicates whether a second template-matching tool isenabled.

Clause 12A: The method of any of clauses 9A-11A, wherein: thetemplate-matching tool is a first template-matching tool, the syntaxelement is a first syntax element, and the method further comprisessignaling, based on the first syntax element, a second syntax elementthat indicates whether a second template-matching tool is enabled.

Clause 13A: The method of clause 9A, wherein: the syntax element is afirst syntax element, wherein the first syntax element indicates whethera first set of one or more template-matching tools are enabled, themethod further comprises signaling a second syntax element in thebitstream, wherein the second syntax element indicates whether a secondset of one or more template-matching tools are enabled, the first set oftemplate-matching tools involve searching an area around an initialmotion vector, and the second set of template-matching tools involvesearching within a list of motion vector candidates.

Clause 14A: The method of any of clauses 9A-13A, wherein: the syntaxelement is a first syntax element, the method further comprises:signaling a second syntax element in the bitstream, wherein the syntaxelement is a sequence-level syntax element, a picture-level syntaxelement, a slice-level syntax element, or a tile-level syntax element;and based on the second syntax element, signaling syntax elements in thebitstream indicating whether template-matching tools are enabled.

Clause 15A: The method of any of clauses 9A-14A, wherein: the methodfurther comprises: based on the syntax element indicating intra-blockcopy template matching merge mode (IBC-TM-MRG) or intra-block copytemplate matching advance motion vector prediction (IBC-TM-AMVP) isdisabled, setting a pruning threshold to a value; and pruning a firstcandidate from a list based on a difference between a motion vectorcomponent of the first candidate and a motion vector component of asecond candidate in the list being less than the pruning threshold, andapplying the template-matching tool to generate the prediction block forthe current CU comprises applying the template-matching tool to generatethe prediction block for the current CU based on a candidate in thelist.

Clause 16A: The method of any of clauses 9A-15A, wherein the syntaxelement is a sequence-level syntax element, a picture-level syntaxelement, a slice-level syntax element, or a tile-level syntax element,and the syntax element indicates that a template-matching tool isenabled.

Clause 17A: A device for coding video data, the device comprising one ormore means for performing the method of any of clauses 1A-16A.

Clause 18A: The device of clause 17A, wherein the one or more meanscomprise one or more processors implemented in circuitry.

Clause 19A: The device of any of clauses 16A and 17A, further comprisinga memory to store the video data.

Clause 20A: The device of any of clauses 17A-19A, further comprising adisplay configured to display decoded video data.

Clause 21A: The device of any of clauses 17A-20A, wherein the devicecomprises one or more of a camera, a computer, a mobile device, abroadcast receiver device, or a set-top box.

Clause 22A: The device of any of clauses 17A-21A, wherein the devicecomprises a video decoder.

Clause 23A: The device of any of clauses 17A-22A, wherein the devicecomprises a video encoder.

Clause 24A: A computer-readable storage medium having stored thereoninstructions that, when executed, cause one or more processors toperform the method of any of clauses 1A-16A.

Clause 1B. A device for decoding video data, the device comprising: amemory comprising one or more storage media, the memory configured tostore the video data; and one or more processors implemented incircuitry, the one or more processors configured to: obtain a syntaxelement from a bitstream that includes an encoded representation of thevideo data; determine, based on the syntax element, that atemplate-matching tool is enabled; based on the template-matching toolbeing enabled, apply the template-matching tool to generate a predictionblock for a current coding unit (CU) of the video data; and reconstructthe current CU based on the prediction block for the current CU.

Example 2B. The device of clause 1B, wherein the template-matching toolis one of: template-matching advanced motion vector prediction(TM-AMVP), geometric partitioning mode (GPM) split mode reordering,candidate reordering for regular merge mode with motion vectordifference (MMVD) and affine MMVD, motion vector difference (MVD) signprediction, reference picture reordering, template-matching merge mode,template-matching GPM, template-matching combined inter-intra prediction(CIIP), adaptive re-ordering of merge candidates, temporal motion vectorprediction (TMVP) and non-adjacent merge candidate type reordering,template-matching overlapped block motion compensation (TM-OBMC), intratemplate matching prediction (IntraTMP), intra-block copy-templatematching-advanced motion vector prediction (IBC-TM-AMVP), or intra-blockcopy-template matching-merge (IBC-TM-AMVP).

Clause 3B. The device of any of clauses 1B-2B, wherein: thetemplate-matching tool is a first template-matching tool, the syntaxelement is a first syntax element, and the one or more processors arefurther configured to determine, based on the first syntax element,whether the bitstream includes a second syntax element that indicateswhether a second template-matching tool is enabled.

Clause 4B. The device of clause 3B, wherein the first template-matchingtool is template-matching merge mode and the second template-matchingtool is template-matching combined intra/inter prediction (CIIP) mode.

Clause 5B. The device of clause 3B, wherein: the first template-matchingtool is adaptive reordering of merge candidates (ARMC), and the secondtemplate-matching tool is one of: geometric partitioning mode (GPM)split mode reordering, candidate reordering for regular merge mode withmotion vector difference (MMVD) and affine MMVD, motion vectordifference (MVD) sign prediction, reference picture reordering, temporalmotion vector prediction (TMVP) or non-adjacent merge candidate typereordering.

Clause 6B. The device of any of clauses 1B-5B, wherein: the syntaxelement is a first syntax element, the one or more processors arefurther configured to: obtain a second syntax element from thebitstream, wherein the second syntax element is a sequence-level syntaxelement, a picture-level syntax element, a slice-level syntax element,or a tile-level syntax element; and determine, based on the secondsyntax element, whether the bitstream includes one or moretemplate-matching tool syntax elements indicating whether one or moretemplate-matching tools are enabled, wherein the template-matching toolsyntax elements include the first syntax element.

Clause 7B. The device of clause 6B, wherein presence of syntax elementsindicating whether intra template matching prediction (intraTMP), intrablock copy template matching with advanced motion vector prediction(IBC-TM-AMVP), and intra block copy template matching with merge mode(IBC-TM-AMVP) are enabled is not dependent on the second syntax element.

Clause 8B. The device of any of clauses 1B-6B, wherein: the one or moreprocessors are further configured to: based on the syntax elementindicating intra-block copy template matching merge mode (IBC-TM-MRG) orintra-block copy template matching advance motion vector prediction(IBC-TM-AMVP) is disabled, set a pruning threshold to a value; and prunea first candidate from a list based on a difference between a motionvector component of the first candidate and a motion vector component ofa second candidate in the list being less than the pruning threshold,and wherein to apply the template-matching tool to generate theprediction block for the current CU, the one or more processors areconfigured to apply the template-matching tool to generate theprediction block for the current CU based on a candidate in the list.

Clause 9B. The device of any of clauses 1B-8B, further comprising adisplay configured to display decoded video data.

Clause 10B. A device for encoding video data, the device comprising: amemory comprising one or more storage media, the memory configured tostore the video data; and one or more processors implemented incircuitry, the one or more processors configured to: signal, in abitstream that includes an encoded representation of the video data, asyntax element that indicates whether a template-matching tool isenabled; based on the template-matching tool being enabled, apply thetemplate-matching tool to generate a prediction block for a currentcoding unit (CU) of the video data; and encode the current CU based onthe prediction block for the current CU.

Clause 11B. The device of clause 10B, wherein the template-matching toolis one of: template-matching advanced motion vector prediction(TM-AMVP), geometric partitioning mode (GPM) split mode reordering,candidate reordering for regular merge mode with motion vectordifference (MMVD) and affine MMVD, motion vector difference (MVD) signprediction, reference picture reordering, template-matching merge mode,template-matching GPM, template-matching combined inter-intra prediction(CIIP), adaptive re-ordering of merge candidates, temporal motion vectorprediction (TMVP) and non-adjacent merge candidate type reordering,template-matching overlapped block motion compensation (TM-OBMC), intratemplate matching prediction (IntraTMP), intra-block copy-templatematching-advanced motion vector prediction (IBC-TM-AMVP), or intra-blockcopy-template matching-merge (IBC-TM-AMVP).

Clause 12B. The device of any of clauses 10B-11B, wherein: thetemplate-matching tool is a first template-matching tool, the syntaxelement is a first syntax element, and the one or more processors arefurther configured to signal, based on the first syntax element, asecond syntax element that indicates whether a second template-matchingtool is enabled.

Clause 13B. The device of clause 12B, wherein the firsttemplate-matching tool is template-matching merge mode and the secondtemplate-matching tool is template-matching combined intra/interprediction (CIIP) mode.

Clause 14B. The device of clause 12B, wherein: the firsttemplate-matching tool is adaptive reordering of merge candidates(ARMC), and the second template-matching tool is one of: geometricpartitioning mode (GPM) split mode reordering, candidate reordering forregular merge mode with motion vector difference (MMVD) and affine MMVD,motion vector difference (MVD) sign prediction, reference picturereordering, temporal motion vector prediction (TMVP) or non-adjacentmerge candidate type reordering.

Clause 15B. The device of any of clauses 10B-14B, wherein: the syntaxelement is a first syntax element, and the one or more processors arefurther configured to signal a second syntax element in the bitstream,the second syntax element indicates whether the bitstream includes oneor more template-matching tool syntax elements, the second syntaxelement is a sequence-level syntax element, a picture-level syntaxelement, a slice-level syntax element, or a tile-level syntax element,and the one or more template-matching tool syntax elements include thefirst syntax element.

Clause 16B. The device of clause 15B, wherein presence of syntaxelements indicating whether intra template matching prediction(intraTMP), intra block copy template matching with advanced motionvector prediction (IBC-TM-AMVP), and intra block copy template matchingwith merge mode (IBC-TM-AMVP) are enabled is not dependent on the secondsyntax element.

Clause 17B. The device of any of clauses 10B-16B, wherein: the one ormore processors are further configured to: based on intra-block copytemplate matching merge mode (IBC-TM-MRG) or intra-block copy templatematching advance motion vector prediction (IBC-TM-AMVP) being disabled,set a pruning threshold to a value; and prune a first candidate from alist based on a difference between a motion vector component of thefirst candidate and a motion vector component of a second candidate inthe list being less than the pruning threshold, and wherein to apply thetemplate-matching tool to generate the prediction block for the currentCU, the one or more processors are further configured to apply thetemplate-matching tool to generate the prediction block for the currentCU based on a candidate in the list.

Clause 18B. The device of any of clauses 10B-17B, wherein the devicecomprises one or more of a camera, a computer, a mobile device, abroadcast receiver device, or a set-top box.

Clause 19B. A method of decoding video data, the method comprising:obtaining a syntax element from a bitstream that includes an encodedrepresentation of the video data; determining, based on the syntaxelement, that a template-matching tool is enabled; based on thetemplate-matching tool being enabled, applying the template-matchingtool to generate a prediction block for a current coding unit (CU) ofthe video data; and reconstructing the current CU based on theprediction block for the current CU.

Clause 20B. The method of clause 19B, wherein the template-matching toolis one of: template-matching advanced motion vector prediction(TM-AMVP), geometric partitioning mode (GPM) split mode reordering,candidate reordering for regular merge mode with motion vectordifference (MMVD) and affine MMVD, motion vector difference (MVD) signprediction, reference picture reordering, template-matching merge mode,template-matching GPM, template-matching combined inter-intra prediction(CLIP), adaptive re-ordering of merge candidates, temporal motion vectorprediction (TMVP) and non-adjacent merge candidate type reordering,template-matching overlapped block motion compensation (TM-OBMC), intratemplate matching prediction (IntraTMP), intra-block copy-templatematching-advanced motion vector prediction (IBC-TM-AMVP), or intra-blockcopy-template matching-merge (IBC-TM-AMVP).

Clause 21B. The method of any of clauses 19B-20B, wherein: thetemplate-matching tool is a first template-matching tool, the syntaxelement is a first syntax element, and the method further comprisesdetermining, based on the first syntax element, whether the bitstreamincludes a syntax element that indicates whether a secondtemplate-matching tool is enabled.

Clause 22B. The method of any of clauses 19B-21B, wherein: the syntaxelement is a first syntax element, the method further comprises:obtaining a second syntax element from the bitstream, wherein the secondsyntax element is a sequence-level syntax element, a picture-levelsyntax element, a slice-level syntax element, or a tile-level syntaxelement; and determining, based on the second syntax element, whetherthe bitstream includes one or more template-matching tool syntaxelements indicating whether one or more template-matching tools areenabled, wherein the template-matching tool syntax elements include thefirst syntax element.

Clause 23B. The method of clause 22B, wherein presence of syntaxelements indicating whether intra template matching prediction(intraTMP), intra block copy template matching with advanced motionvector prediction (IBC-TM-AMVP), and intra block copy template matchingwith merge mode (IBC-TM-AMVP) is not dependent on the second syntaxelement.

Clause 24B. The method of any of clauses 19B-23B, wherein: the methodfurther comprises: based on the syntax element indicating intra-blockcopy template matching merge mode (IBC-TM-MRG) or intra-block copytemplate matching advance motion vector prediction (IBC-TM-AMVP) isdisabled, setting a pruning threshold to a value; and pruning a firstcandidate from a list based on a difference between a motion vectorcomponent of the first candidate and a motion vector component of asecond candidate in the list being less than the pruning threshold, andapplying the template-matching tool to generate the prediction block forthe current CU comprises applying the template-matching tool to generatethe prediction block for the current CU based on a candidate in thelist.

Clause 25B. A method of encoding video data, the method comprising:signaling, in a bitstream that includes an encoded representation of thevideo data, a syntax element that indicates whether a template-matchingtool is enabled; based on the template-matching tool being enabled,applying the template-matching tool to generate a prediction block for acurrent coding unit (CU) of the video data; and encoding the current CUbased on the prediction block for the current CU.

Clause 26B. The method of clause 25B, wherein the template-matching toolis one of: template-matching advanced motion vector prediction(TM-AMVP), geometric partitioning mode (GPM) split mode reordering,candidate reordering for regular merge mode with motion vectordifference (MMVD) and affine MMVD, motion vector difference (MVD) signprediction, reference picture reordering, template-matching merge mode,template-matching GPM, template-matching combined inter-intra prediction(CIIP), adaptive re-ordering of merge candidates, temporal motion vectorprediction (TMVP) and non-adjacent merge candidate type reordering,template-matching overlapped block motion compensation (TM-OBMC), intratemplate matching prediction (IntraTMP), intra-block copy-templatematching-advanced motion vector prediction (IBC-TM-AMVP), or intra-blockcopy-template matching-merge (IBC-TM-AMVP).

Clause 27B. The method of any of clauses 25B-26B, wherein: thetemplate-matching tool is a first template-matching tool, the syntaxelement is a first syntax element, and the method further comprisessignaling, based on the first syntax element, a second syntax elementthat indicates whether a second template-matching tool is enabled.

Clause 28B. The method of clause 27B, wherein: the firsttemplate-matching tool is adaptive reordering of merge candidates(ARMC), and the second template-matching tool is one of: geometricpartitioning mode (GPM) split mode reordering, candidate reordering forregular merge mode with motion vector difference (MMVD) and affine MMVD,motion vector difference (MVD) sign prediction, reference picturereordering, temporal motion vector prediction (TMVP) or non-adjacentmerge candidate type reordering.

Clause 30B. The method of any of clauses 25B-29B, wherein: the syntaxelement is a first syntax element, the method further comprisessignaling a second syntax element in the bitstream, the second syntaxelement indicates whether the bitstream includes one or moretemplate-matching tool syntax elements, the second syntax element is asequence-level syntax element, a picture-level syntax element, aslice-level syntax element, or a tile-level syntax element, and the oneor more template-matching tool syntax elements include the first syntaxelement.

Clause 31B. The method of any of clauses 25B-29B, wherein: the methodfurther comprises: based on intra-block copy template matching mergemode (IBC-TM-MRG) or intra-block copy template matching advance motionvector prediction (IBC-TM-AMVP) being disabled, setting a pruningthreshold to a value; and pruning a first candidate from a list based ona difference between a motion vector component of the first candidateand a motion vector component of a second candidate in the list beingless than the pruning threshold, and applying the template-matching toolto generate the prediction block for the current CU comprises applyingthe template-matching tool to generate the prediction block for thecurrent CU based on a candidate in the list.

It is to be recognized that depending on the example, certain acts orevents of any of the techniques described herein can be performed in adifferent sequence, may be added, merged, or left out altogether (e.g.,not all described acts or events are necessary for the practice of thetechniques). Moreover, in certain examples, acts or events may beperformed concurrently, e.g., through multi-threaded processing,interrupt processing, or multiple processors, rather than sequentially.

In one or more examples, the functions described may be implemented inhardware, software, firmware, or any combination thereof. If implementedin software, the functions may be stored on or transmitted over as oneor more instructions or code on a computer-readable medium and executedby a hardware-based processing unit. Computer-readable media may includecomputer-readable storage media, which corresponds to a tangible mediumsuch as data storage media, or communication media including any mediumthat facilitates transfer of a computer program from one place toanother, e.g., according to a communication protocol. In this manner,computer-readable media generally may correspond to (1) tangiblecomputer-readable storage media which is non-transitory or (2) acommunication medium such as a signal or carrier wave. Data storagemedia may be any available media that can be accessed by one or morecomputers or one or more processors to retrieve instructions, codeand/or data structures for implementation of the techniques described inthis disclosure. A computer program product may include acomputer-readable medium.

By way of example, and not limitation, such computer-readable storagemedia can comprise RAM, ROM, EEPROM, CD-ROM or other optical diskstorage, magnetic disk storage, or other magnetic storage devices, flashmemory, or any other medium that can be used to store desired programcode in the form of instructions or data structures and that can beaccessed by a computer. Also, any connection is properly termed acomputer-readable medium. For example, if instructions are transmittedfrom a website, server, or other remote source using a coaxial cable,fiber optic cable, twisted pair, digital subscriber line (DSL), orwireless technologies such as infrared, radio, and microwave, then thecoaxial cable, fiber optic cable, twisted pair, DSL, or wirelesstechnologies such as infrared, radio, and microwave are included in thedefinition of medium. It should be understood, however, thatcomputer-readable storage media and data storage media do not includeconnections, carrier waves, signals, or other transitory media, but areinstead directed to non-transitory, tangible storage media. Disk anddisc, as used herein, includes compact disc (CD), laser disc, opticaldisc, digital versatile disc (DVD), floppy disk and Blu-ray disc, wheredisks usually reproduce data magnetically, while discs reproduce dataoptically with lasers. Combinations of the above should also be includedwithin the scope of computer-readable media.

Instructions may be executed by one or more processors, such as one ormore DSPs, general purpose microprocessors, ASICs, FPGAs, or otherequivalent integrated or discrete logic circuitry. Accordingly, theterms “processor” and “processing circuitry,” as used herein may referto any of the foregoing structures or any other structure suitable forimplementation of the techniques described herein. In addition, in someaspects, the functionality described herein may be provided withindedicated hardware and/or software modules configured for encoding anddecoding, or incorporated in a combined codec. Also, the techniquescould be fully implemented in one or more circuits or logic elements.

The techniques of this disclosure may be implemented in a wide varietyof devices or apparatuses, including a wireless handset, an integratedcircuit (IC) or a set of ICs (e.g., a chip set). Various components,modules, or units are described in this disclosure to emphasizefunctional aspects of devices configured to perform the disclosedtechniques, but do not necessarily require realization by differenthardware units. Rather, as described above, various units may becombined in a codec hardware unit or provided by a collection ofinteroperative hardware units, including one or more processors asdescribed above, in conjunction with suitable software and/or firmware.

Various examples have been described. These and other examples arewithin the scope of the following claims.

What is claimed is:
 1. A device for decoding video data, the devicecomprising: a memory comprising one or more storage media, the memoryconfigured to store the video data; and one or more processorsimplemented in circuitry, the one or more processors configured to:obtain a syntax element from a bitstream that includes an encodedrepresentation of the video data; determine, based on the syntaxelement, that a template-matching tool is enabled; based on thetemplate-matching tool being enabled, apply the template-matching toolto generate a prediction block for a current coding unit (CU) of thevideo data; and reconstruct the current CU based on the prediction blockfor the current CU.
 2. The device of claim 1, wherein thetemplate-matching tool is one of: template-matching advanced motionvector prediction (TM-AMVP), geometric partitioning mode (GPM) splitmode reordering, candidate reordering for regular merge mode with motionvector difference (MMVD) and affine MMVD, motion vector difference (MVD)sign prediction, reference picture reordering, template-matching mergemode, template-matching GPM, template-matching combined inter-intraprediction (CIIP), adaptive re-ordering of merge candidates, temporalmotion vector prediction (TMVP) and non-adjacent merge candidate typereordering, template-matching overlapped block motion compensation(TM-OBMC), intra template matching prediction (IntraTMP), intra-blockcopy-template matching-advanced motion vector prediction (IBC-TM-AMVP),or intra-block copy-template matching-merge (IBC-TM-AMVP).
 3. The deviceof claim 1, wherein: the template-matching tool is a firsttemplate-matching tool, the syntax element is a first syntax element,and the one or more processors are further configured to determine,based on the first syntax element, whether the bitstream includes asecond syntax element that indicates whether a second template-matchingtool is enabled.
 4. The device of claim 3, wherein the firsttemplate-matching tool is template-matching merge mode and the secondtemplate-matching tool is template-matching combined intra/interprediction (CIIP) mode.
 5. The device of claim 3, wherein: the firsttemplate-matching tool is adaptive reordering of merge candidates(ARMC), and the second template-matching tool is one of: geometricpartitioning mode (GPM) split mode reordering, candidate reordering forregular merge mode with motion vector difference (MMVD) and affine MMVD,motion vector difference (MVD) sign prediction, reference picturereordering, temporal motion vector prediction (TMVP) or non-adjacentmerge candidate type reordering.
 6. The device of claim 1, wherein: thesyntax element is a first syntax element, the one or more processors arefurther configured to: obtain a second syntax element from thebitstream, wherein the second syntax element is a sequence-level syntaxelement, a picture-level syntax element, a slice-level syntax element,or a tile-level syntax element; and determine, based on the secondsyntax element, whether the bitstream includes one or moretemplate-matching tool syntax elements indicating whether one or moretemplate-matching tools are enabled, wherein the template-matching toolsyntax elements include the first syntax element.
 7. The device of claim6, wherein presence of syntax elements indicating whether intra templatematching prediction (intraTMP), intra block copy template matching withadvanced motion vector prediction (IBC-TM-AMVP), and intra block copytemplate matching with merge mode (IBC-TM-AMVP) are enabled is notdependent on the second syntax element.
 8. The device of claim 1,wherein: the one or more processors are further configured to: based onthe syntax element indicating intra-block copy template matching mergemode (IBC-TM-MRG) or intra-block copy template matching advance motionvector prediction (IBC-TM-AMVP) is disabled, set a pruning threshold toa value; and prune a first candidate from a list based on a differencebetween a motion vector component of the first candidate and a motionvector component of a second candidate in the list being less than thepruning threshold, and wherein to apply the template-matching tool togenerate the prediction block for the current CU, the one or moreprocessors are configured to apply the template-matching tool togenerate the prediction block for the current CU based on a candidate inthe list.
 9. The device of claim 1, further comprising a displayconfigured to display decoded video data.
 10. A device for encodingvideo data, the device comprising: a memory comprising one or morestorage media, the memory configured to store the video data; and one ormore processors implemented in circuitry, the one or more processorsconfigured to: signal, in a bitstream that includes an encodedrepresentation of the video data, a syntax element that indicateswhether a template-matching tool is enabled; based on thetemplate-matching tool being enabled, apply the template-matching toolto generate a prediction block for a current coding unit (CU) of thevideo data; and encode the current CU based on the prediction block forthe current CU.
 11. The device of claim 10, wherein thetemplate-matching tool is one of: template-matching advanced motionvector prediction (TM-AMVP), geometric partitioning mode (GPM) splitmode reordering, candidate reordering for regular merge mode with motionvector difference (MMVD) and affine MMVD, motion vector difference (MVD)sign prediction, reference picture reordering, template-matching mergemode, template-matching GPM, template-matching combined inter-intraprediction (CIIP), adaptive re-ordering of merge candidates, temporalmotion vector prediction (TMVP) and non-adjacent merge candidate typereordering, template-matching overlapped block motion compensation(TM-OBMC), intra template matching prediction (IntraTMP), intra-blockcopy-template matching-advanced motion vector prediction (IBC-TM-AMVP),or intra-block copy-template matching-merge (IBC-TM-AMVP).
 12. Thedevice of claim 10, wherein: the template-matching tool is a firsttemplate-matching tool, the syntax element is a first syntax element,and the one or more processors are further configured to signal, basedon the first syntax element, a second syntax element that indicateswhether a second template-matching tool is enabled.
 13. The device ofclaim 12, wherein the first template-matching tool is template-matchingmerge mode and the second template-matching tool is template-matchingcombined intra/inter prediction (CIIP) mode.
 14. The device of claim 12,wherein: the first template-matching tool is adaptive reordering ofmerge candidates (ARMC), and the second template-matching tool is oneof: geometric partitioning mode (GPM) split mode reordering, candidatereordering for regular merge mode with motion vector difference (MMVD)and affine MMVD, motion vector difference (MVD) sign prediction,reference picture reordering, temporal motion vector prediction (TMVP)or non-adjacent merge candidate type reordering.
 15. The device of claim10, wherein: the syntax element is a first syntax element, and the oneor more processors are further configured to signal a second syntaxelement in the bitstream, the second syntax element indicates whetherthe bitstream includes one or more template-matching tool syntaxelements, the second syntax element is a sequence-level syntax element,a picture-level syntax element, a slice-level syntax element, or atile-level syntax element, and the one or more template-matching toolsyntax elements include the first syntax element.
 16. The device ofclaim 15, wherein presence of syntax elements indicating whether intratemplate matching prediction (intraTMP), intra block copy templatematching with advanced motion vector prediction (IBC-TM-AMVP), and intrablock copy template matching with merge mode (IBC-TM-AMVP) are enabledis not dependent on the second syntax element.
 17. The device of claim10, wherein: the one or more processors are further configured to: basedon intra-block copy template matching merge mode (IBC-TM-MRG) orintra-block copy template matching advance motion vector prediction(IBC-TM-AMVP) being disabled, set a pruning threshold to a value; andprune a first candidate from a list based on a difference between amotion vector component of the first candidate and a motion vectorcomponent of a second candidate in the list being less than the pruningthreshold, and wherein to apply the template-matching tool to generatethe prediction block for the current CU, the one or more processors arefurther configured to apply the template-matching tool to generate theprediction block for the current CU based on a candidate in the list.18. The device of claim 10, wherein the device comprises one or more ofa camera, a computer, a mobile device, a broadcast receiver device, or aset-top box.
 19. A method of decoding video data, the method comprising:obtaining a syntax element from a bitstream that includes an encodedrepresentation of the video data; determining, based on the syntaxelement, that a template-matching tool is enabled; based on thetemplate-matching tool being enabled, applying the template-matchingtool to generate a prediction block for a current coding unit (CU) ofthe video data; and reconstructing the current CU based on theprediction block for the current CU.
 20. The method of claim 19, whereinthe template-matching tool is one of: template-matching advanced motionvector prediction (TM-AMVP), geometric partitioning mode (GPM) splitmode reordering, candidate reordering for regular merge mode with motionvector difference (MMVD) and affine MMVD, motion vector difference (MVD)sign prediction, reference picture reordering, template-matching mergemode, template-matching GPM, template-matching combined inter-intraprediction (CIIP), adaptive re-ordering of merge candidates, temporalmotion vector prediction (TMVP) and non-adjacent merge candidate typereordering, template-matching overlapped block motion compensation(TM-OBMC), intra template matching prediction (IntraTMP), intra-blockcopy-template matching-advanced motion vector prediction (IBC-TM-AMVP),or intra-block copy-template matching-merge (IBC-TM-AMVP).
 21. Themethod of claim 19, wherein: the template-matching tool is a firsttemplate-matching tool, the syntax element is a first syntax element,and the method further comprises determining, based on the first syntaxelement, whether the bitstream includes a syntax element that indicateswhether a second template-matching tool is enabled.
 22. The method ofclaim 19, wherein: the syntax element is a first syntax element, themethod further comprises: obtaining a second syntax element from thebitstream, wherein the second syntax element is a sequence-level syntaxelement, a picture-level syntax element, a slice-level syntax element,or a tile-level syntax element; and determining, based on the secondsyntax element, whether the bitstream includes one or moretemplate-matching tool syntax elements indicating whether one or moretemplate-matching tools are enabled, wherein the template-matching toolsyntax elements include the first syntax element.
 23. The method ofclaim 22, wherein presence of syntax elements indicating whether intratemplate matching prediction (intraTMP), intra block copy templatematching with advanced motion vector prediction (IBC-TM-AMVP), and intrablock copy template matching with merge mode (IBC-TM-AMVP) is notdependent on the second syntax element.
 24. The method of claim 19,wherein: the method further comprises: based on the syntax elementindicating intra-block copy template matching merge mode (IBC-TM-MRG) orintra-block copy template matching advance motion vector prediction(IBC-TM-AMVP) is disabled, setting a pruning threshold to a value; andpruning a first candidate from a list based on a difference between amotion vector component of the first candidate and a motion vectorcomponent of a second candidate in the list being less than the pruningthreshold, and applying the template-matching tool to generate theprediction block for the current CU comprises applying thetemplate-matching tool to generate the prediction block for the currentCU based on a candidate in the list.
 25. A method of encoding videodata, the method comprising: signaling, in a bitstream that includes anencoded representation of the video data, a syntax element thatindicates whether a template-matching tool is enabled; based on thetemplate-matching tool being enabled, applying the template-matchingtool to generate a prediction block for a current coding unit (CU) ofthe video data; and encoding the current CU based on the predictionblock for the current CU.
 26. The method of claim 25, wherein thetemplate-matching tool is one of: template-matching advanced motionvector prediction (TM-AMVP), geometric partitioning mode (GPM) splitmode reordering, candidate reordering for regular merge mode with motionvector difference (MMVD) and affine MMVD, motion vector difference (MVD)sign prediction, reference picture reordering, template-matching mergemode, template-matching GPM, template-matching combined inter-intraprediction (CIIP), adaptive re-ordering of merge candidates, temporalmotion vector prediction (TMVP) and non-adjacent merge candidate typereordering, template-matching overlapped block motion compensation(TM-OBMC), intra template matching prediction (IntraTMP), intra-blockcopy-template matching-advanced motion vector prediction (IBC-TM-AMVP),or intra-block copy-template matching-merge (IBC-TM-AMVP).
 27. Themethod of claim 25, wherein: the template-matching tool is a firsttemplate-matching tool, the syntax element is a first syntax element,and the method further comprises signaling, based on the first syntaxelement, a second syntax element that indicates whether a secondtemplate-matching tool is enabled.
 28. The method of claim 27, wherein:the first template-matching tool is adaptive reordering of mergecandidates (ARMC), and the second template-matching tool is one of:geometric partitioning mode (GPM) split mode reordering, candidatereordering for regular merge mode with motion vector difference (MMVD)and affine MMVD, motion vector difference (MVD) sign prediction,reference picture reordering, temporal motion vector prediction (TMVP)or non-adjacent merge candidate type reordering.
 29. The method of claim25, wherein: the syntax element is a first syntax element, the methodfurther comprises signaling a second syntax element in the bitstream,the second syntax element indicates whether the bitstream includes oneor more template-matching tool syntax elements, the second syntaxelement is a sequence-level syntax element, a picture-level syntaxelement, a slice-level syntax element, or a tile-level syntax element,and the one or more template-matching tool syntax elements include thefirst syntax element.
 30. The method of claim 25, wherein: the methodfurther comprises: based on intra-block copy template matching mergemode (IBC-TM-MRG) or intra-block copy template matching advance motionvector prediction (IBC-TM-AMVP) being disabled, setting a pruningthreshold to a value; and pruning a first candidate from a list based ona difference between a motion vector component of the first candidateand a motion vector component of a second candidate in the list beingless than the pruning threshold, and applying the template-matching toolto generate the prediction block for the current CU comprises applyingthe template-matching tool to generate the prediction block for thecurrent CU based on a candidate in the list.